Ticket #7972: argvorder.diff
File argvorder.diff, 2.8 KB (added by , 16 years ago) |
---|
-
django/core/management/base.py
70 70 parser = self.create_parser(prog_name, subcommand) 71 71 parser.print_help() 72 72 73 def run_from_argv(self, argv):74 parser = self.create_parser( argv[0], argv[1])75 options, args = parser.parse_args(argv [2:])73 def run_from_argv(self, prog_name, subcommand, argv): 74 parser = self.create_parser(prog_name, subcommand) 75 options, args = parser.parse_args(argv) 76 76 handle_default_options(options) 77 self.execute(*args, **options.__dict__) 77 prog_args = args[2:] 78 self.execute(*prog_args, **options.__dict__) 78 79 79 80 def execute(self, *args, **options): 80 81 # Switch to English, because django-admin.py creates database content -
django/core/management/__init__.py
226 226 pass # Ignore any option errors at this point. 227 227 228 228 try: 229 subcommand = self.argv[1]229 subcommand = args[1] 230 230 except IndexError: 231 231 sys.stderr.write("Type '%s help' for usage.\n" % self.prog_name) 232 232 sys.exit(1) … … 245 245 elif self.argv[1:] == ['--help']: 246 246 sys.stderr.write(self.main_help_text() + '\n') 247 247 else: 248 self.fetch_command(subcommand).run_from_argv( self.argv)248 self.fetch_command(subcommand).run_from_argv(args[0], args[1], sys.argv) 249 249 250 250 class ProjectManagementUtility(ManagementUtility): 251 251 """ -
tests/regressiontests/admin_scripts/tests.py
910 910 self.assertNoOutput(err) 911 911 self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', 'y'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None)]") 912 912 913 def test_setting_then_command_then_label_then_options(self): 914 "Options are correctly handled when they are passed before and after a setting" 915 args = ['--settings=alternate_settings','base_command','testlabel','--option_a=x','--option_b=y'] 916 out, err = self.run_manage(args) 917 self.assertNoOutput(err) 918 self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', 'y'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None)]") 919