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

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