def main(initial_args=None): if initial_args is None: initial_args = sys.argv[1:] autocomplete() version_control() options, args = parser.parse_args(initial_args) if options.help and not args: args = ['help'] if not args: parser.error( 'You must give a command (use "pip help" to see a list of commands)' ) command = args[0].lower() load_command(command) if command not in command_dict: close_commands = difflib.get_close_matches(command, command_names()) if close_commands: guess = close_commands[0] if args[1:]: guess = "%s %s" % (guess, " ".join(args[1:])) else: guess = 'install %s' % command error_dict = { 'arg': command, 'guess': guess, 'script': os.path.basename(sys.argv[0]) } parser.error('No command by the name %(script)s %(arg)s\n ' '(maybe you meant "%(script)s %(guess)s")' % error_dict) command = command_dict[command] return command.main(args[1:], options)
def main(initial_args=None): if initial_args is None: initial_args = sys.argv[1:] autocomplete() version_control() options, args = parser.parse_args(initial_args) if options.help and not args: args = ['help'] if not args: parser.error('You must give a command (use "pip help" to see a list of commands)') command = args[0].lower() load_command(command) if command not in command_dict: close_commands = difflib.get_close_matches(command, command_names()) if close_commands: guess = close_commands[0] if args[1:]: guess = "{0!s} {1!s}".format(guess, " ".join(args[1:])) else: guess = 'install {0!s}'.format(command) error_dict = {'arg': command, 'guess': guess, 'script': os.path.basename(sys.argv[0])} parser.error('No command by the name %(script)s %(arg)s\n ' '(maybe you meant "%(script)s %(guess)s")' % error_dict) command = command_dict[command] return command.main(initial_args, args[1:], options)
def main(initial_args=None): if initial_args is None: initial_args = sys.argv[1:] autocomplete() options, args = parser.parse_args(initial_args) if options.help and not args: args = ["help"] if not args: parser.error("You must give a command " '(use "%s help" to see a list of commands)' % get_prog()) command = args[0].lower() load_command(command) if command not in command_dict: close_commands = difflib.get_close_matches(command, command_names()) if close_commands: guess = close_commands[0] if args[1:]: guess = "%s %s" % (guess, " ".join(args[1:])) else: guess = "install %s" % command error_dict = {"arg": command, "guess": guess, "script": os.path.basename(sys.argv[0])} parser.error( "No command by the name %(script)s %(arg)s\n " '(maybe you meant "%(script)s %(guess)s")' % error_dict ) command = command_dict[command] return command.main(args[1:], options)
def main(initial_args=None): if initial_args is None: initial_args = sys.argv[1:] autocomplete() options, args = parser.parse_args(initial_args) if options.help and not args: args = ['help'] if not args: parser.error('You must give a command (use "pip help" see a list of commands)') command = args[0].lower() load_command(command) ## FIXME: search for a command match? if command not in command_dict: parser.error('No command by the name %(script)s %(arg)s\n (maybe you meant "%(script)s install %(arg)s")' % dict(script=os.path.basename(sys.argv[0]), arg=command)) command = command_dict[command] return command.main(initial_args, args[1:], options)
def main(initial_args=None): if initial_args is None: initial_args = sys.argv[1:] autocomplete() options, args = parser.parse_args(initial_args) if options.help and not args: args = ['help'] if not args: parser.error('You must give a command?') cmd = 'requisite' fn = 'requisite.commands.%s' % cmd try: __import__(fn) except ImportError: pass command = command_dict[cmd] return command.main(args, options)