Add a cargo_no_command rule

This commit is contained in:
mcarton
2015-06-06 17:06:10 +02:00
parent 01cf199866
commit f6c013d033
3 changed files with 37 additions and 1 deletions
+14
View File
@@ -0,0 +1,14 @@
import re
def match(command, settings):
return ('cargo' in command.script
and 'No such subcommand' in command.stderr
and 'Did you mean' in command.stderr)
def get_new_command(command, settings):
broken = command.script.split()[1]
fix = re.findall(r'Did you mean `([^`]*)`', command.stderr)[0]
return command.script.replace(broken, fix, 1)