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

Rename pyenv rule

This commit is contained in:
gkodosis 2020-05-08 19:11:59 +03:00
parent b4dadebd5f
commit 1ac2325479

View File

@ -1,33 +0,0 @@
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('pyenv')
def match(command):
return 'pyenv: no such command' in command.output
def get_pyenv_commands():
proc = Popen(['pyenv', 'commands'], stdout=PIPE)
return [line.decode('utf-8').strip() for line in proc.stdout.readlines()]
if which('pyenv'):
get_pyenv_commands = cache(which('pyenv'))(get_pyenv_commands)
@for_app('pyenv')
def get_new_command(command):
broken = re.findall(r"pyenv: 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_pyenv_commands()))
return matched