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

make missing_space_before_subcommand return all possible correct command lines

This commit is contained in:
braham delam 2019-12-02 10:33:18 -05:00
parent 628bc8dddf
commit 19c80c88e3

View File

@ -1,27 +1,32 @@
from thefuck.utils import get_all_executables, memoize
@memoize
def _get_executable(script_part):
def _get_executables(script_part):
executable_list = []
for executable in get_all_executables():
if script_part.startswith(executable):
if executable.startswith("apt"):
if script_part.startswith("apt-get"):
if len(script_part) > len("apt-get"):
return "apt-get"
else:
return
return executable
executable_list.append(executable)
return executable_list
def match(command):
return (not command.script_parts[0] in get_all_executables()
and _get_executable(command.script_parts[0]))
and len(_get_executables(command.script_parts[0])) != 0)
def get_new_command(command):
executable = _get_executable(command.script_parts[0])
return command.script.replace(executable, u'{} '.format(executable), 1)
executables = _get_executables(command.script_parts[0])
new_command_scripts = []
# return all possible command lines
for each_exec in executables:
temp_line = command.script
new_command_scripts.append(temp_line.replace(
each_exec, u'{} '.format(each_exec), 1))
return new_command_scripts
priority = 4000