Commits

Ask Solem Hoel committed 602d63f

Move parts of Manager.handle to Command.handle so commands can override how remaining_args is used.

  • Participants
  • Parent commits 9658dd4

Comments (0)

Files changed (1)

File flaskext/script.py

         
         return parser
 
+    def handle(self, app, prog, name, remaining_args):
+        command_parser = self.create_parser(prog + " " + name)
+        if getattr(self, 'capture_all_args', False):
+            command_namespace, unparsed_args = \
+                command_parser.parse_known_args(remaining_args)
+            positional_args = [unparsed_args]
+        else:
+            command_namespace = command_parser.parse_args(remaining_args)
+            positional_args = []
+
+        with app.test_request_context():
+            self.run(*positional_args, **command_namespace.__dict__)
+
     def run(self):
 
         """
             if arg in args:
                 remaining_args.append(arg)
 
-        command_parser = command.create_parser(prog + " " + name)
-        if getattr(command, 'capture_all_args', False):
-            command_namespace, unparsed_args = \
-                command_parser.parse_known_args(remaining_args)
-            positional_args = [unparsed_args]
-        else:
-            command_namespace = command_parser.parse_args(remaining_args)
-            positional_args = []
-        
         app = self.create_app(**app_namespace.__dict__)
-
-        with app.test_request_context():
-            command.run(*positional_args, **command_namespace.__dict__)
+        command.handle(app, prog, name, remaining_args)
 
     def run(self, commands=None):