1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-25 03:59:08 +00:00
thefuck/thefuck/rules/goenv_no_such_command.py
2020-07-06 14:31:36 +03:00

24 lines
728 B
Python

import re
from thefuck.utils import cache, for_app, replace_argument, replace_command, which
from thefuck.specific.devenv import env_available, COMMON_TYPOS, get_commands
enabled_by_default = env_available
@for_app('goenv')
def match(command):
return 'goenv: no such command' in command.output
if which('goenv'):
get_commands = cache(which('goenv'))(get_commands)
@for_app('goenv')
def get_new_command(command):
broken = re.findall(r"goenv: no such command '([^']*)'", command.output)[0]
matched = [replace_argument(command.script, broken, common_typo)
for common_typo in COMMON_TYPOS.get(broken, [])]
matched.extend(replace_command(command, broken, get_commands()))
return matched