2011-08-02 19:54:18 +02:00
|
|
|
from pip.basecommand import (Command, command_dict,
|
|
|
|
load_all_commands, SUCCESS,
|
|
|
|
ERROR)
|
2011-08-02 19:41:31 +02:00
|
|
|
from pip.exceptions import CommandError
|
2009-11-20 19:20:52 +01:00
|
|
|
from pip.baseparser import parser
|
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2009-11-20 19:20:52 +01:00
|
|
|
class HelpCommand(Command):
|
|
|
|
name = 'help'
|
|
|
|
usage = '%prog'
|
|
|
|
summary = 'Show available commands'
|
|
|
|
|
|
|
|
def run(self, options, args):
|
|
|
|
load_all_commands()
|
|
|
|
if args:
|
|
|
|
## FIXME: handle errors better here
|
|
|
|
command = args[0]
|
|
|
|
if command not in command_dict:
|
2011-08-02 19:41:31 +02:00
|
|
|
raise CommandError('No command with the name: %s' % command)
|
2009-11-20 19:20:52 +01:00
|
|
|
command = command_dict[command]
|
|
|
|
command.parser.print_help()
|
2011-08-02 19:41:31 +02:00
|
|
|
return SUCCESS
|
2009-11-20 19:20:52 +01:00
|
|
|
parser.print_help()
|
2011-03-15 20:49:48 +01:00
|
|
|
print('\nCommands available:')
|
2009-11-20 19:20:52 +01:00
|
|
|
commands = list(set(command_dict.values()))
|
|
|
|
commands.sort(key=lambda x: x.name)
|
|
|
|
for command in commands:
|
|
|
|
if command.hidden:
|
|
|
|
continue
|
2011-03-15 20:49:48 +01:00
|
|
|
print(' %s: %s' % (command.name, command.summary))
|
2011-08-02 19:41:31 +02:00
|
|
|
return SUCCESS
|
2010-06-03 04:25:26 +02:00
|
|
|
|