瀏覽代碼

add createsuperuser flag to server command

Nick Sweeting 4 年之前
父節點
當前提交
39ec77e46c
共有 2 個文件被更改,包括 10 次插入0 次删除
  1. 6 0
      archivebox/cli/archivebox_server.py
  2. 4 0
      archivebox/main.py

+ 6 - 0
archivebox/cli/archivebox_server.py

@@ -43,6 +43,11 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
         action='store_true',
         action='store_true',
         help='Run archivebox init before starting the server',
         help='Run archivebox init before starting the server',
     )
     )
+    parser.add_argument(
+        '--createsuperuser',
+        action='store_true',
+        help='Run archivebox manage createsuperuser before starting the server',
+    )
     command = parser.parse_args(args or ())
     command = parser.parse_args(args or ())
     reject_stdin(__command__, stdin)
     reject_stdin(__command__, stdin)
     
     
@@ -51,6 +56,7 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
         reload=command.reload,
         reload=command.reload,
         debug=command.debug,
         debug=command.debug,
         init=command.init,
         init=command.init,
+        createsuperuser=command.createsuperuser,
         out_dir=pwd or OUTPUT_DIR,
         out_dir=pwd or OUTPUT_DIR,
     )
     )
 
 

+ 4 - 0
archivebox/main.py

@@ -1060,6 +1060,7 @@ def server(runserver_args: Optional[List[str]]=None,
            reload: bool=False,
            reload: bool=False,
            debug: bool=False,
            debug: bool=False,
            init: bool=False,
            init: bool=False,
+           createsuperuser: bool=False,
            out_dir: Path=OUTPUT_DIR) -> None:
            out_dir: Path=OUTPUT_DIR) -> None:
     """Run the ArchiveBox HTTP server"""
     """Run the ArchiveBox HTTP server"""
 
 
@@ -1068,6 +1069,9 @@ def server(runserver_args: Optional[List[str]]=None,
     if init:
     if init:
         run_subcommand('init', stdin=None, pwd=out_dir)
         run_subcommand('init', stdin=None, pwd=out_dir)
 
 
+    if createsuperuser:
+        run_subcommand('manage', subcommand_args=['createsuperuser'], pwd=out_dir)
+
     # setup config for django runserver
     # setup config for django runserver
     from . import config
     from . import config
     config.SHOW_PROGRESS = False
     config.SHOW_PROGRESS = False