1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 06:38:32 +00:00

globalize pyenv rule

This commit is contained in:
gkodosis 2020-05-08 19:04:44 +03:00
parent 6975d30818
commit b4dadebd5f

View File

@ -0,0 +1,34 @@
import re
from subprocess import PIPE, Popen
from thefuck.utils import (cache, for_app, replace_argument, replace_command,
which)
COMMON_TYPOS = {
'list': ['versions', 'install --list'],
'remove': ['uninstall'],
}
@for_app('env')
def match(command):
return ('env' in command.script and
'command not found' in command.output)
def get_env_commands():
proc_env = Popen(['env', 'commands'], stdout=PIPE)
return [line.decode('utf-8').strip() for line in proc_env.stdout.readlines()]
if which('env'):
get_env_commands = cache(which('env'))(get_env_commands)
@for_app('env')
def get_new_command(command):
broken = re.findall(r"command not found `([^']*)'", 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_env_commands()))
return matched