home · contact · privacy
Allow calling mere "ytplom" rather than "ytplom serve" to default to latter. master
authorChristian Heller <c.heller@plomlompom.de>
Mon, 10 Feb 2025 13:55:18 +0000 (14:55 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 10 Feb 2025 13:55:18 +0000 (14:55 +0100)
src/run.py

index c94838c617fb643f6557b63fdf1bb3d5ede8b700..d400e0e6b4b0bc3677eef1e22c67ecacc1c710c3 100755 (executable)
@@ -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)