mirror of https://github.com/pypa/pip
fix error output
`pip help <misspelled>` should return the same error message as `pip <misspelled>`, namely: ERROR: unknown command "enstall" - maybe you meant "install"
This commit is contained in:
parent
e103e549d7
commit
715c7eff71
|
@ -128,7 +128,7 @@ def parseopts(args):
|
|||
if guess:
|
||||
msg.append('maybe you meant "%s"' % guess)
|
||||
|
||||
raise CommandError(' - '.join(msg)) # TODO:
|
||||
raise CommandError(' - '.join(msg))
|
||||
|
||||
return command, options, args, parser
|
||||
|
||||
|
@ -143,7 +143,7 @@ def main(initial_args=None):
|
|||
cmd_name, options, args, parser = parseopts(initial_args)
|
||||
except PipError:
|
||||
e = sys.exc_info()[1]
|
||||
sys.stderr.write(str(e))
|
||||
sys.stderr.write("ERROR: %s" % e)
|
||||
sys.stderr.write(os.linesep)
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class HelpCommand(Command):
|
|||
summary = 'Show available commands'
|
||||
|
||||
def run(self, options, args):
|
||||
from pip.commands import commands
|
||||
from pip.commands import commands, get_similar_commands
|
||||
|
||||
try:
|
||||
# 'pip help' with no args is handled by pip.__init__.parseopt()
|
||||
|
@ -17,7 +17,13 @@ class HelpCommand(Command):
|
|||
return SUCCESS
|
||||
|
||||
if cmd_name not in commands:
|
||||
raise CommandError('unknown command "%s"' % cmd_name)
|
||||
guess = get_similar_commands(cmd_name)
|
||||
|
||||
msg = ['unknown command "%s"' % cmd_name]
|
||||
if guess:
|
||||
msg.append('maybe you meant "%s"' % guess)
|
||||
|
||||
raise CommandError(' - '.join(msg))
|
||||
|
||||
command = commands[cmd_name](self.main_parser) # instantiate
|
||||
command.parser.print_help()
|
||||
|
|
Loading…
Reference in New Issue