You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

help.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from __future__ import absolute_import
  2. from pip._internal.cli.base_command import Command
  3. from pip._internal.cli.status_codes import SUCCESS
  4. from pip._internal.exceptions import CommandError
  5. class HelpCommand(Command):
  6. """Show help for commands"""
  7. name = 'help'
  8. usage = """
  9. %prog <command>"""
  10. summary = 'Show help for commands.'
  11. ignore_require_venv = True
  12. def run(self, options, args):
  13. from pip._internal.commands import commands_dict, get_similar_commands
  14. try:
  15. # 'pip help' with no args is handled by pip.__init__.parseopt()
  16. cmd_name = args[0] # the command we need help for
  17. except IndexError:
  18. return SUCCESS
  19. if cmd_name not in commands_dict:
  20. guess = get_similar_commands(cmd_name)
  21. msg = ['unknown command "%s"' % cmd_name]
  22. if guess:
  23. msg.append('maybe you meant "%s"' % guess)
  24. raise CommandError(' - '.join(msg))
  25. command = commands_dict[cmd_name]()
  26. command.parser.print_help()
  27. return SUCCESS