Skip to content

Commit

Permalink
Improve pip -h and pip help
Browse files Browse the repository at this point in the history
  • Loading branch information
ianb committed Jan 29, 2009
1 parent 073246a commit 077118c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/news.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ tip
* Fixes when installing editable packages that put their source in a
subdirectory (like ``src/``).

* Improve ``pip -h``

0.3
---

Expand Down
15 changes: 12 additions & 3 deletions pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,14 @@ def get_backend_from_location(self, location):

parser = optparse.OptionParser(
usage='%prog COMMAND [OPTIONS]',
version=version)
version=version,
add_help_option=False)

parser.add_option(
'-h', '--help',
dest='help',
action='store_true',
help='Show help')
parser.add_option(
'-E', '--environment',
dest='venv',
Expand Down Expand Up @@ -192,7 +198,7 @@ def __init__(self):
prog='%s %s' % (sys.argv[0], self.name),
version=parser.version)
for option in parser.option_list:
if not option.dest:
if not option.dest or option.dest == 'help':
# -h, --version, etc
continue
self.parser.add_option(option)
Expand Down Expand Up @@ -277,7 +283,8 @@ def run(self, options, args):
command = _commands[command]
command.parser.print_help()
return
print 'Usage: %s [COMMAND] ...' % os.path.basename(sys.argv[0])
parser.print_help()
print
print 'Commands available:'
commands = list(set(_commands.values()))
commands.sort(key=lambda x: x.name)
Expand Down Expand Up @@ -874,6 +881,8 @@ def main(initial_args=None):
if initial_args is None:
initial_args = sys.argv[1:]
options, args = parser.parse_args(initial_args)
if options.help and not args:
args = ['help']
if not args:
parser.error('You must give a command (use "pip help" see a list of commands)')
command = args[0].lower()
Expand Down

0 comments on commit 077118c

Please sign in to comment.