An 'invalid argument' output
This commit is contained in:
parent
a55ce5a390
commit
9948cd85ae
35
glogger.py
35
glogger.py
@ -6,11 +6,15 @@ import editpost
|
|||||||
import rebuild
|
import rebuild
|
||||||
import initialise
|
import initialise
|
||||||
|
|
||||||
|
help_text = '''
|
||||||
|
If no argument is passed, glogger will ask for a username;
|
||||||
|
if that user exists, it will as if you want to create a new post, or edit a post (TODO)
|
||||||
|
--help Output this help text
|
||||||
|
--rebuild Rewrite every static page in the site
|
||||||
|
--config={configuration file path} Specify the file path of the configuration
|
||||||
|
'''
|
||||||
|
|
||||||
config_file_path = "config.py"
|
config_file_path = "config.py"
|
||||||
if len(sys.argv) > 1:
|
|
||||||
for argument in sys.argv:
|
|
||||||
if argument[:9] == "--config=":
|
|
||||||
config_file_path = argument[9:]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import posts
|
import posts
|
||||||
@ -33,18 +37,27 @@ except:
|
|||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
for argument in sys.argv:
|
for argument in sys.argv:
|
||||||
|
if argument == "glogger.py":
|
||||||
|
continue
|
||||||
if argument == "--help":
|
if argument == "--help":
|
||||||
print('''
|
print(help_text)
|
||||||
If no argument is passed, glogger will ask for a username;
|
|
||||||
if that user exists, it will as if you want to create a new post, or edit a post (TODO)
|
|
||||||
--help Output this help text
|
|
||||||
--rebuild Rewrite every static page in the site
|
|
||||||
--config={configuration file path} Specify the file path of the configuration
|
|
||||||
''')
|
|
||||||
exit()
|
exit()
|
||||||
if argument == "--rebuild":
|
if argument == "--rebuild":
|
||||||
rebuild.rebuild()
|
rebuild.rebuild()
|
||||||
exit()
|
exit()
|
||||||
|
if argument[:9] == "--config=":
|
||||||
|
config_file_path = argument[9:]
|
||||||
|
try:
|
||||||
|
config = SourceFileLoader("config", config_file_path).load_module()
|
||||||
|
if config.autogenerated == True:
|
||||||
|
print("Error: autogenerated = True")
|
||||||
|
exit()
|
||||||
|
except:
|
||||||
|
print(f"{config_file_path} does not exist")
|
||||||
|
exit()
|
||||||
|
else:
|
||||||
|
print(f"Invalid Argument: {argument}")
|
||||||
|
print(help_text)
|
||||||
|
|
||||||
username = input("Username: ").lower()
|
username = input("Username: ").lower()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user