2019-09-28 20:12:49 +02:00
|
|
|
# The following comment should be removed at some point in the future.
|
|
|
|
# mypy: disallow-untyped-defs=False
|
|
|
|
|
2014-08-31 01:52:28 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2018-07-30 06:16:25 +02:00
|
|
|
from pip._internal.cli.base_command import Command
|
|
|
|
from pip._internal.cli.status_codes import SUCCESS
|
2017-08-31 17:48:18 +02:00
|
|
|
from pip._internal.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"""
|
2019-07-10 09:36:33 +02:00
|
|
|
|
2013-01-18 22:25:15 +01:00
|
|
|
usage = """
|
|
|
|
%prog <command>"""
|
2017-05-18 15:20:01 +02:00
|
|
|
ignore_require_venv = True
|
2009-11-20 19:20:52 +01:00
|
|
|
|
|
|
|
def run(self, options, args):
|
2019-07-10 09:36:33 +02:00
|
|
|
from pip._internal.commands import (
|
|
|
|
commands_dict, create_command, 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
|
|
|
|
2014-12-02 16:47:36 +01:00
|
|
|
if cmd_name not in commands_dict:
|
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
|
|
|
|
2019-07-10 09:36:33 +02:00
|
|
|
command = create_command(cmd_name)
|
2012-11-10 05:17:58 +01:00
|
|
|
command.parser.print_help()
|
|
|
|
|
|
|
|
return SUCCESS
|