Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hhhrrrttt222111
GitHub Repository: hhhrrrttt222111/Dorkify
Path: blob/master/venv/Lib/site-packages/pip/_internal/commands/help.py
811 views
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 "{}"'.format(cmd_name)]
33
if guess:
34
msg.append('maybe you meant "{}"'.format(guess))
35
36
raise CommandError(' - '.join(msg))
37
38
command = create_command(cmd_name)
39
command.parser.print_help()
40
41
return SUCCESS
42
43