mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 01:28:56 +00:00
Test pyenv change
This commit is contained in:
parent
269ff4e0e7
commit
cc2a6d5d67
@ -1,6 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
from thefuck.utils import cache, for_app, replace_argument, replace_command, which
|
from thefuck.utils import cache, for_app, replace_argument, replace_command, which
|
||||||
from thefuck.specific.devenv import env_available, COMMON_TYPOS, get_commands
|
from thefuck.specific.devenv import env_available, COMMON_TYPOS
|
||||||
|
from subprocess import PIPE, Popen
|
||||||
|
|
||||||
enabled_by_default = env_available
|
enabled_by_default = env_available
|
||||||
|
|
||||||
@ -10,6 +11,11 @@ def match(command):
|
|||||||
return 'pyenv: no such command' in command.output
|
return 'pyenv: no such command' in command.output
|
||||||
|
|
||||||
|
|
||||||
|
def get_commands():
|
||||||
|
proc = Popen(['pyenv', 'commands'], stdout=PIPE)
|
||||||
|
return [line.decode('utf-8').strip() for line in proc.stdout.readlines()]
|
||||||
|
|
||||||
|
|
||||||
if which('pyenv'):
|
if which('pyenv'):
|
||||||
get_commands = cache(which('pyenv'))(get_commands)
|
get_commands = cache(which('pyenv'))(get_commands)
|
||||||
|
|
||||||
@ -19,5 +25,5 @@ def get_new_command(command):
|
|||||||
broken = re.findall(r"pyenv: no such command `([^']*)'", command.output)[0]
|
broken = re.findall(r"pyenv: no such command `([^']*)'", command.output)[0]
|
||||||
matched = [replace_argument(command.script, broken, common_typo)
|
matched = [replace_argument(command.script, broken, common_typo)
|
||||||
for common_typo in COMMON_TYPOS.get(broken, [])]
|
for common_typo in COMMON_TYPOS.get(broken, [])]
|
||||||
matched.extend(replace_command(command, broken, get_commands(command.script_parts[0])))
|
matched.extend(replace_command(command, broken, get_commands()))
|
||||||
return matched
|
return matched
|
||||||
|
Loading…
x
Reference in New Issue
Block a user