#298 Suggest more than one result in *_no_command rules
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from thefuck.utils import get_closest, replace_argument
|
||||
from thefuck.utils import get_closest, replace_command
|
||||
|
||||
BREW_CMD_PATH = '/Library/Homebrew/cmd'
|
||||
TAP_PATH = '/Library/Taps'
|
||||
@@ -77,10 +77,6 @@ if brew_path_prefix:
|
||||
pass
|
||||
|
||||
|
||||
def _get_similar_command(command):
|
||||
return get_closest(command, brew_commands)
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
is_proper_command = ('brew' in command.script and
|
||||
'Unknown command' in command.stderr)
|
||||
@@ -89,7 +85,7 @@ def match(command, settings):
|
||||
if is_proper_command:
|
||||
broken_cmd = re.findall(r'Error: Unknown command: ([a-z]+)',
|
||||
command.stderr)[0]
|
||||
has_possible_commands = bool(_get_similar_command(broken_cmd))
|
||||
has_possible_commands = bool(get_closest(broken_cmd, brew_commands))
|
||||
|
||||
return has_possible_commands
|
||||
|
||||
@@ -97,6 +93,4 @@ def match(command, settings):
|
||||
def get_new_command(command, settings):
|
||||
broken_cmd = re.findall(r'Error: Unknown command: ([a-z]+)',
|
||||
command.stderr)[0]
|
||||
new_cmd = _get_similar_command(broken_cmd)
|
||||
|
||||
return replace_argument(command.script, broken_cmd, new_cmd)
|
||||
return replace_command(command, broken_cmd, brew_commands)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from itertools import dropwhile, takewhile, islice
|
||||
import re
|
||||
import subprocess
|
||||
from thefuck.utils import get_closest, sudo_support, replace_argument
|
||||
from thefuck.utils import get_closest, sudo_support, replace_argument, replace_command
|
||||
|
||||
|
||||
@sudo_support
|
||||
@@ -23,5 +23,4 @@ def get_docker_commands():
|
||||
def get_new_command(command, settings):
|
||||
wrong_command = re.findall(
|
||||
r"docker: '(\w+)' is not a docker command.", command.stderr)[0]
|
||||
fixed_command = get_closest(wrong_command, get_docker_commands())
|
||||
return replace_argument(command.script, wrong_command, fixed_command)
|
||||
return replace_command(command, wrong_command, get_docker_commands())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import re
|
||||
from thefuck.utils import (get_closest, git_support, replace_argument,
|
||||
get_all_matched_commands)
|
||||
from thefuck.utils import (git_support,
|
||||
get_all_matched_commands, replace_command)
|
||||
|
||||
|
||||
@git_support
|
||||
@@ -13,7 +13,5 @@ def match(command, settings):
|
||||
def get_new_command(command, settings):
|
||||
broken_cmd = re.findall(r"git: '([^']*)' is not a git command",
|
||||
command.stderr)[0]
|
||||
new_cmd = get_closest(broken_cmd,
|
||||
get_all_matched_commands(command.stderr))
|
||||
return replace_argument(command.script, broken_cmd, new_cmd)
|
||||
|
||||
matched = get_all_matched_commands(command.stderr)
|
||||
return replace_command(command, broken_cmd, matched)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import re
|
||||
import subprocess
|
||||
from thefuck.utils import get_closest, replace_argument
|
||||
from thefuck.utils import replace_command
|
||||
|
||||
|
||||
def match(command, script):
|
||||
@@ -18,5 +18,4 @@ def get_gulp_tasks():
|
||||
def get_new_command(command, script):
|
||||
wrong_task = re.findall(r"Task '(\w+)' is not in your gulpfile",
|
||||
command.stdout)[0]
|
||||
fixed_task = get_closest(wrong_task, get_gulp_tasks())
|
||||
return replace_argument(command.script, wrong_task, fixed_task)
|
||||
return replace_command(command, wrong_task, get_gulp_tasks())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import re
|
||||
from thefuck.utils import get_closest, replace_argument
|
||||
from thefuck.utils import replace_command
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
@@ -16,5 +16,4 @@ def _get_suggests(stderr):
|
||||
|
||||
def get_new_command(command, settings):
|
||||
wrong = re.findall(r'`(\w+)` is not a heroku command', command.stderr)[0]
|
||||
correct = get_closest(wrong, _get_suggests(command.stderr))
|
||||
return replace_argument(command.script, wrong, correct)
|
||||
return replace_command(command, wrong, _get_suggests(command.stderr))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import re
|
||||
from thefuck.utils import sudo_support, replace_argument
|
||||
from thefuck.utils import sudo_support,\
|
||||
replace_command, get_all_matched_commands
|
||||
|
||||
|
||||
@sudo_support
|
||||
@@ -13,6 +14,5 @@ def match(command, settings):
|
||||
def get_new_command(command, settings):
|
||||
broken_cmd = re.findall(r"'([^']*)' is not a task",
|
||||
command.stderr)[0]
|
||||
new_cmd = re.findall(r'Did you mean this\?\n\s*([^\n]*)',
|
||||
command.stderr)[0]
|
||||
return replace_argument(command.script, broken_cmd, new_cmd)
|
||||
new_cmds = get_all_matched_commands(command.stderr, 'Did you mean this?')
|
||||
return replace_command(command, broken_cmd, new_cmds)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from difflib import get_close_matches
|
||||
from thefuck.utils import sudo_support, get_all_executables, get_closest
|
||||
from thefuck.utils import sudo_support, get_all_executables
|
||||
|
||||
|
||||
@sudo_support
|
||||
@@ -12,8 +12,9 @@ def match(command, settings):
|
||||
@sudo_support
|
||||
def get_new_command(command, settings):
|
||||
old_command = command.script.split(' ')[0]
|
||||
new_command = get_closest(old_command, get_all_executables())
|
||||
return ' '.join([new_command] + command.script.split(' ')[1:])
|
||||
new_cmds = get_close_matches(old_command, get_all_executables(), cutoff=0.1)
|
||||
return [' '.join([new_command] + command.script.split(' ')[1:])
|
||||
for new_command in new_cmds]
|
||||
|
||||
|
||||
priority = 3000
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import re
|
||||
from thefuck.utils import (get_closest, replace_argument,
|
||||
get_all_matched_commands)
|
||||
get_all_matched_commands, replace_command)
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
@@ -12,7 +12,6 @@ def match(command, settings):
|
||||
def get_new_command(command, settings):
|
||||
broken_cmd = re.findall(r'tsuru: "([^"]*)" is not a tsuru command',
|
||||
command.stderr)[0]
|
||||
new_cmd = get_closest(broken_cmd,
|
||||
get_all_matched_commands(command.stderr))
|
||||
return replace_argument(command.script, broken_cmd, new_cmd)
|
||||
return replace_command(command, broken_cmd,
|
||||
get_all_matched_commands(command.stderr))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user