PageRenderTime 30ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 1ms

/bangkokhotel/lib/python2.5/site-packages/pip-1.2.1-py2.5.egg/pip/commands/help.py

https://bitbucket.org/luisrodriguez/bangkokhotel
Python | 33 lines | 28 code | 4 blank | 1 comment | 4 complexity | 892cf40ac8348cb552947d7ed12963e2 MD5 | raw file
  1. from pip.basecommand import (Command, command_dict,
  2. load_all_commands, SUCCESS,
  3. ERROR)
  4. from pip.exceptions import CommandError
  5. from pip.baseparser import parser
  6. class HelpCommand(Command):
  7. name = 'help'
  8. usage = '%prog'
  9. summary = 'Show available commands'
  10. def run(self, options, args):
  11. load_all_commands()
  12. if args:
  13. ## FIXME: handle errors better here
  14. command = args[0]
  15. if command not in command_dict:
  16. raise CommandError('No command with the name: %s' % command)
  17. command = command_dict[command]
  18. command.parser.print_help()
  19. return SUCCESS
  20. parser.print_help()
  21. print('\nCommands available:')
  22. commands = list(set(command_dict.values()))
  23. commands.sort(key=lambda x: x.name)
  24. for command in commands:
  25. if command.hidden:
  26. continue
  27. print(' %s: %s' % (command.name, command.summary))
  28. return SUCCESS
  29. HelpCommand()