Changeset 6089
- Timestamp:
- 09/10/07 22:46:35 (1 year ago)
- Files:
-
- django/trunk/django/core/management/base.py (modified) (1 diff)
- django/trunk/django/core/management/__init__.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/base.py
r6088 r6089 50 50 option_list=self.option_list) 51 51 52 def print_help(self, argv):53 parser = self.create_parser( argv[0])52 def print_help(self, prog_name): 53 parser = self.create_parser(prog_name) 54 54 parser.print_help() 55 55 56 def run (self, argv):56 def run_from_argv(self, argv): 57 57 parser = self.create_parser(argv[0]) 58 58 options, args = parser.parse_args(argv[1:]) django/trunk/django/core/management/__init__.py
r6088 r6089 52 52 return dict([(name, load_command_class(name)) for name in names]) 53 53 54 def print_help(self, argv):54 def print_help(self, prog_name): 55 55 """ 56 56 Returns the help message, as a string. 57 57 """ 58 prog_name = os.path.basename( argv[0])58 prog_name = os.path.basename(prog_name) 59 59 usage = ['%s <subcommand> [options] [args]' % prog_name] 60 60 usage.append('Django command line tool, version %s' % django.get_version()) … … 67 67 print '\n'.join(usage) 68 68 69 def fetch_command(self, subcommand, command_name):69 def fetch_command(self, subcommand, prog_name): 70 70 """ 71 71 Tries to fetch the given subcommand, printing a message with the … … 76 76 return self.commands[subcommand] 77 77 except KeyError: 78 sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" % (subcommand, command_name))78 sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" % (subcommand, prog_name)) 79 79 sys.exit(1) 80 80 81 81 def execute(self, argv=None): 82 82 """ 83 Figures out which command is being run (the first arg), creates a parser84 appropriate to that command, and runs it.83 Given the command-line arguments, this figures out which subcommand is 84 being run, creates a parser appropriate to that command, and runs it. 85 85 """ 86 86 if argv is None: … … 94 94 if subcommand == 'help': 95 95 if len(argv) > 2: 96 self.fetch_command(argv[2], argv[0]).print_help(argv[ 2:])96 self.fetch_command(argv[2], argv[0]).print_help(argv[0]) 97 97 else: 98 self.print_help(argv )98 self.print_help(argv[0]) 99 99 # Special-cases: We want 'django-admin.py --version' and 100 100 # 'django-admin.py --help' to work, for backwards compatibility. … … 102 102 print django.get_version() 103 103 elif argv[1:] == ['--help']: 104 self.print_help(argv )104 self.print_help(argv[0]) 105 105 else: 106 self.fetch_command(subcommand, argv[0]).run (argv[1:])106 self.fetch_command(subcommand, argv[0]).run_from_argv(argv[1:]) 107 107 108 108 class ProjectManagementUtility(ManagementUtility):
