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.
 
 
 
 

36 lines
982 B

  1. from __future__ import absolute_import
  2. from pip.basecommand import Command, SUCCESS
  3. from pip.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. def run(self, options, args):
  11. from pip.commands import commands_dict, get_similar_commands
  12. try:
  13. # 'pip help' with no args is handled by pip.__init__.parseopt()
  14. cmd_name = args[0] # the command we need help for
  15. except IndexError:
  16. return SUCCESS
  17. if cmd_name not in commands_dict:
  18. guess = get_similar_commands(cmd_name)
  19. msg = ['unknown command "%s"' % cmd_name]
  20. if guess:
  21. msg.append('maybe you meant "%s"' % guess)
  22. raise CommandError(' - '.join(msg))
  23. command = commands_dict[cmd_name]()
  24. command.parser.print_help()
  25. return SUCCESS