Commits

Michael Elsdörfer committed 2da2a69 Merge

Merged the dangling 85779ce25e96 head into default. This includes mainly Ask's Command.handle() refactor, which is now responsible for the argument parsing, allowing custom commands to overwrite the parsing behavior. For example, if a custom command wraps around some other libraries command parsing code, it can simply parse the original argv list along unmodified. This thus replaces the 'capture_all_args' functionality which previously attempted to do the same thing.

Comments (0)

Files changed (1)

flaskext/script.py

 import string
 import getpass
 import inspect
-import warnings
 
 import argparse
 
         
         return parser
 
-    def handle(self, app, *args, **kwargs):
+    def handle(self, app, prog, name, remaining_args):
         """
         Handles the command with given app. Default behaviour is to call within
         a test request context.
-        """
+        """	
+        command_parser = self.create_parser(prog + " " + name)
+        command_namespace = command_parser.parse_args(remaining_args)
         with app.test_request_context():
-            self.run(*args, **kwargs)
+            self.run(**command_namespace.__dict__)
 
     def run(self):
 
 
         raise NotImplementedError
 
-    def prompt(self, name, default=None):
-        warnings.warn_explicit(
-            "Command.prompt is deprecated, use prompt() function instead")
-
-        prompt(name, default)
-
-    def prompt_pass(self, name, default=None):
-        warnings.warn_explicit(
-            "Command.prompt_pass is deprecated, use prompt_pass() function instead")
-
-        prompt_pass(name, default)
-
-    def prompt_bool(self, name, default=False):
-        warnings.warn_explicit(
-            "Command.prompt_bool is deprecated, use prompt_bool() function instead")
-
-        prompt_bool(name, default)
-
-    def prompt_choices(self, name, choices, default=None):
-        warnings.warn_explicit(
-            "Command.choices is deprecated, use prompt_choices() function instead")
-
-        prompt_choices(name, choices, default)
 
 class Shell(Command):
 
 
         rv = []
 
-        for name, command in self._commands.iteritems():
+        for name, command in sorted(self._commands.iteritems()):
             usage = name
             description = command.description or ''
             usage = format % (name, description)
             if arg in args:
                 remaining_args.append(arg)
 
-        command_parser = command.create_parser(prog + " " + name)
-        command_namespace = command_parser.parse_args(remaining_args)
-        
         app = self.create_app(**app_namespace.__dict__)
-
-        command.handle(app, **command_namespace.__dict__)
+        command.handle(app, prog, name, remaining_args)
 
     def run(self, commands=None, default_command=None):