Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/pip/_internal/commands/help.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 from pip._internal.cli.base_command import Command | |
2 from pip._internal.cli.status_codes import SUCCESS | |
3 from pip._internal.exceptions import CommandError | |
4 from pip._internal.utils.typing import MYPY_CHECK_RUNNING | |
5 | |
6 if MYPY_CHECK_RUNNING: | |
7 from optparse import Values | |
8 from typing import List | |
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 # type: (Values, List[str]) -> int | |
20 from pip._internal.commands import ( | |
21 commands_dict, | |
22 create_command, | |
23 get_similar_commands, | |
24 ) | |
25 | |
26 try: | |
27 # 'pip help' with no args is handled by pip.__init__.parseopt() | |
28 cmd_name = args[0] # the command we need help for | |
29 except IndexError: | |
30 return SUCCESS | |
31 | |
32 if cmd_name not in commands_dict: | |
33 guess = get_similar_commands(cmd_name) | |
34 | |
35 msg = [f'unknown command "{cmd_name}"'] | |
36 if guess: | |
37 msg.append(f'maybe you meant "{guess}"') | |
38 | |
39 raise CommandError(' - '.join(msg)) | |
40 | |
41 command = create_command(cmd_name) | |
42 command.parser.print_help() | |
43 | |
44 return SUCCESS |