1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-20 17:48:41 +00:00
thefuck/thefuck/rules/lein_not_task.py

20 lines
661 B
Python
Raw Normal View History

2015-04-18 23:19:34 +02:00
import re
from thefuck.utils import replace_command, get_all_matched_commands, for_app
from thefuck.specific.sudo import sudo_support
2015-04-18 23:19:34 +02:00
@sudo_support
@for_app('lein')
2015-04-18 23:19:34 +02:00
def match(command, settings):
return (command.script.startswith('lein')
and "is not a task. See 'lein help'" in command.stderr
and 'Did you mean this?' in command.stderr)
@sudo_support
2015-04-18 23:19:34 +02:00
def get_new_command(command, settings):
broken_cmd = re.findall(r"'([^']*)' is not a task",
command.stderr)[0]
new_cmds = get_all_matched_commands(command.stderr, 'Did you mean this?')
return replace_command(command, broken_cmd, new_cmds)