refactor: Move backward compatible argument handling into config loader

This commit is contained in:
Vikash Kothary 2022-10-14 22:58:50 +01:00
parent 1402321e00
commit 153ac4227a
2 changed files with 6 additions and 5 deletions

View File

@ -19,11 +19,7 @@ def main():
"ankisyncd {} ({})".format(ankisyncd._get_version(), ankisyncd._homepage)
)
if len(sys.argv) > 1:
# backwards compat
config = ankisyncd.config.load(sys.argv[1])
else:
config = ankisyncd.config.load()
config = ankisyncd.config.load(sys.argv)
ankiserver = SyncApp(config)
run_server(ankiserver, config["host"], int(config["port"]))

View File

@ -26,6 +26,11 @@ def load_from_env(conf):
def load(path=None):
# backwards compat
if len(path) > 1:
path = path[1]
else:
path = None
choices = paths
parser = configparser.ConfigParser()
if path: