1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-11-16 06:46:03 +00:00
Files
thefuck/thefuck/rules/cargo_no_command.py
2015-10-29 00:13:59 +08:00

16 lines
409 B
Python

import re
from thefuck.utils import replace_argument, for_app
@for_app('cargo', at_least=1)
def match(command):
return ('No such subcommand' in command.stderr
and 'Did you mean' in command.stderr)
def get_new_command(command):
broken = command.script_parts[1]
fix = re.findall(r'Did you mean `([^`]*)`', command.stderr)[0]
return replace_argument(command.script, broken, fix)