Opened 15 years ago
Closed 15 years ago
#11842 closed (fixed)
django-admin.py should display help output when no arguments are given
Reported by: | Jeff Forcier | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Ticket #378 mentions having django-admin.py
honor Unix traditions -- and yet if you invoke it with no arguments, you get a profoundly unfriendly and non-Unix-like message:
$ django-admin.py Type 'django-admin.py help' for usage.
Compare to, say, apt-get
:
$ apt-get apt 0.7.9ubuntu17.2 for i386 compiled on Apr 17 2009 16:29:24 Usage: apt-get [options] command apt-get [options] install|remove pkg1 [pkg2 ...] apt-get [options] source pkg1 [pkg2 ...] [...]
or git:
$ git usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS] [...]
I'm sure I didn't need to give examples, but I felt like being thorough :)
The code related to this has not changed significantly since the 1.0.X branch -- i.e. the (tiny) patch applies cleanly to the latest 1.0.X branch checkout, as well as the latest SVN.
I'm not seeing any tests that apply to django-admin.py at all, so not including one -- please point me to the right spot if I've missed something.
Attachments (1)
Change History (7)
by , 15 years ago
comment:1 by , 15 years ago
Summary: | `django-admin.py` should display `--help` output when no arguments are given → django-admin.py should display help output when no arguments are given |
---|
comment:2 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 15 years ago
Patch needs improvement: | set |
---|
comment:4 by , 15 years ago
It actually does still exit with return code of 1, see end-of-line comments added to below snippet:
try: subcommand = self.argv[1] except IndexError: subcommand = 'help' # Here's what my patch changes, sets subcommand to 'help' if subcommand == 'help': # So this is then true if len(args) > 2: # This is almost definitely false self.fetch_command(args[2]).print_help(self.prog_name, args[2]) else: # So we branch to here parser.print_lax_help() sys.stderr.write(self.main_help_text() + '\n') sys.exit(1) # And exit 1
Let me know if I'm still missing something :) (I note that we could theoretically put in logic to skip the len(args)
check in this situation, which would add a bit more state -- but not sure if that's worth it.)
comment:5 by , 15 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
That's fine. I was only triaging the content of the patch, not actually looking at code :)
Promoted!
comment:6 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
It should still use
sys.exit(1)