From: Christian Heller Date: Mon, 10 Feb 2025 13:55:18 +0000 (+0100) Subject: Allow calling mere "ytplom" rather than "ytplom serve" to default to latter. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/booking/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D/ledger2?a=commitdiff_plain;h=HEAD;p=ytplom Allow calling mere "ytplom" rather than "ytplom serve" to default to latter. --- diff --git a/src/run.py b/src/run.py index c94838c..d400e0e 100755 --- a/src/run.py +++ b/src/run.py @@ -18,21 +18,26 @@ except ModuleNotFoundError as e: if __name__ == '__main__': try: - if 2 != len(argv): - raise HandledException('Bad number of command arguments.') - match argv[1]: - case 'install_deps': - raise HandledException('Should be handled by calling script.') - case 'create_db': - DbFile.create() - case 'migrate_db': - DbFile(skip_validations=True).migrate(MIGRATIONS) - case 'serve': + match len(argv): + case 1: serve() - case 'sync': - sync() + case 2: + match argv[1]: + case 'install_deps': + raise HandledException( + 'Should be handled by calling script.') + case 'create_db': + DbFile.create() + case 'migrate_db': + DbFile(skip_validations=True).migrate(MIGRATIONS) + case 'serve': + serve() + case 'sync': + sync() + case _: + raise HandledException('Unknown argument.') case _: - raise HandledException('Unknown argument.') + raise HandledException('Bad number of command arguments.') except HandledException as e: print(e) sys_exit(1)