Opened 7 years ago

Closed 7 years ago

#11842 closed (fixed) should display help output when no arguments are given

Reported by: bitprophet Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Ticket #378 mentions having honor Unix traditions -- and yet if you invoke it with no arguments, you get a profoundly unfriendly and non-Unix-like message:

Type ' 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 at all, so not including one -- please point me to the right spot if I've missed something.

Attachments (1)

my.patch (524 bytes) - added by bitprophet 7 years ago.

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by bitprophet

comment:1 Changed 7 years ago by bitprophet

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from `` should display `--help` output when no arguments are given to should display help output when no arguments are given

comment:2 Changed 7 years ago by bastih

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 7 years ago by SmileyChris

  • Patch needs improvement set

It should still use sys.exit(1)

comment:4 Changed 7 years ago by bitprophet

It actually does still exit with return code of 1, see end-of-line comments added to below snippet:

            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
                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 Changed 7 years ago by SmileyChris

  • Patch needs improvement unset
  • Triage Stage changed from Accepted to Ready for checkin

That's fine. I was only triaging the content of the patch, not actually looking at code :)


comment:6 Changed 7 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [12198]) Fixed #11842 -- now displays usage information if invoked with no arguments. Thanks, bitprophet

Note: See TracTickets for help on using tickets.
Back to Top