2013-02-16 19:02:41 +01:00
|
|
|
from pip.basecommand import Command, SUCCESS
|
2011-08-02 19:41:31 +02:00
|
|
|
from pip.exceptions import CommandError
|
2009-11-20 19:20:52 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2009-11-20 19:20:52 +01:00
|
|
|
class HelpCommand(Command):
|
2013-02-16 19:00:29 +01:00
|
|
|
"""Show help for commands"""
|
2009-11-20 19:20:52 +01:00
|
|
|
name = 'help'
|
2013-01-18 22:25:15 +01:00
|
|
|
usage = """
|
|
|
|
%prog <command>"""
|
|
|
|
summary = 'Show help for commands.'
|
2009-11-20 19:20:52 +01:00
|
|
|
|
|
|
|
def run(self, options, args):
|
2012-12-06 16:22:04 +01:00
|
|
|
from pip.commands import commands, get_similar_commands
|
2012-11-10 05:17:58 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
# 'pip help' with no args is handled by pip.__init__.parseopt()
|
2012-12-06 15:56:46 +01:00
|
|
|
cmd_name = args[0] # the command we need help for
|
2012-12-06 16:01:54 +01:00
|
|
|
except IndexError:
|
2011-08-02 19:41:31 +02:00
|
|
|
return SUCCESS
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2012-11-10 05:17:58 +01:00
|
|
|
if cmd_name not in commands:
|
2012-12-06 16:22:04 +01:00
|
|
|
guess = get_similar_commands(cmd_name)
|
|
|
|
|
|
|
|
msg = ['unknown command "%s"' % cmd_name]
|
|
|
|
if guess:
|
|
|
|
msg.append('maybe you meant "%s"' % guess)
|
|
|
|
|
|
|
|
raise CommandError(' - '.join(msg))
|
2012-11-10 05:17:58 +01:00
|
|
|
|
2013-09-17 07:21:15 +02:00
|
|
|
command = commands[cmd_name]()
|
2012-11-10 05:17:58 +01:00
|
|
|
command.parser.print_help()
|
|
|
|
|
|
|
|
return SUCCESS
|