Пример #1
0
def main():
    options, args = parser.parse_args(sys.argv[1:])
    if options.help and not args:
        args = ['help']
    if not args:
        args = ['help'] # as default
    init_home()
    load_all_commands()
    command = args[0].lower()
    if command not in command_dict:
        parser.error("Unknown command: `%s`" % command)
        return
    command = command_dict[command]
    command.run(args[1:])
Пример #2
0
 def run_command(self, options, args):
     if args:
         command = args[0]
         if command not in command_dict:
             parser.error("Unknown command: `%s`" % command)
             return
         command = command_dict[command]
         command.parser.print_help()
         return
     parser.print_help()
     logger.log("\nCommands available:")
     commands = [command_dict[key] for key in sorted(command_dict.keys())]
     for command in commands:
         logger.log("  %s: %s" % (command.name, command.summary))
     logger.log("\nFurther Instructions:")
     logger.log("  https://github.com/saghul/pythonz")