diff --git a/glogger.py b/glogger.py index f1fd8d3..8f90c3e 100755 --- a/glogger.py +++ b/glogger.py @@ -6,11 +6,15 @@ import editpost import rebuild 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" -if len(sys.argv) > 1: - for argument in sys.argv: - if argument[:9] == "--config=": - config_file_path = argument[9:] try: import posts @@ -33,18 +37,27 @@ except: if len(sys.argv) > 1: for argument in sys.argv: + if argument == "glogger.py": + continue if argument == "--help": - print(''' -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 - ''') + print(help_text) exit() if argument == "--rebuild": rebuild.rebuild() 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()