comparison lib/python3.8/site-packages/pip/_internal/commands/help.py @ 0:9e54283cc701 draft

"planemo upload commit d12c32a45bcd441307e632fca6d9af7d60289d44"
author guerler
date Mon, 27 Jul 2020 03:47:31 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:9e54283cc701
1 # The following comment should be removed at some point in the future.
2 # mypy: disallow-untyped-defs=False
3
4 from __future__ import absolute_import
5
6 from pip._internal.cli.base_command import Command
7 from pip._internal.cli.status_codes import SUCCESS
8 from pip._internal.exceptions import CommandError
9
10
11 class HelpCommand(Command):
12 """Show help for commands"""
13
14 usage = """
15 %prog <command>"""
16 ignore_require_venv = True
17
18 def run(self, options, args):
19 from pip._internal.commands import (
20 commands_dict, create_command, get_similar_commands,
21 )
22
23 try:
24 # 'pip help' with no args is handled by pip.__init__.parseopt()
25 cmd_name = args[0] # the command we need help for
26 except IndexError:
27 return SUCCESS
28
29 if cmd_name not in commands_dict:
30 guess = get_similar_commands(cmd_name)
31
32 msg = ['unknown command "%s"' % cmd_name]
33 if guess:
34 msg.append('maybe you meant "%s"' % guess)
35
36 raise CommandError(' - '.join(msg))
37
38 command = create_command(cmd_name)
39 command.parser.print_help()
40
41 return SUCCESS