mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 01:28:56 +00:00
make missing_space_before_subcommand return all possible correct command lines
This commit is contained in:
parent
628bc8dddf
commit
19c80c88e3
@ -1,27 +1,32 @@
|
|||||||
|
|
||||||
from thefuck.utils import get_all_executables, memoize
|
from thefuck.utils import get_all_executables, memoize
|
||||||
|
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
def _get_executable(script_part):
|
def _get_executables(script_part):
|
||||||
|
executable_list = []
|
||||||
for executable in get_all_executables():
|
for executable in get_all_executables():
|
||||||
if script_part.startswith(executable):
|
if script_part.startswith(executable):
|
||||||
if executable.startswith("apt"):
|
executable_list.append(executable)
|
||||||
if script_part.startswith("apt-get"):
|
return executable_list
|
||||||
if len(script_part) > len("apt-get"):
|
|
||||||
return "apt-get"
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
return executable
|
|
||||||
|
|
||||||
|
|
||||||
def match(command):
|
def match(command):
|
||||||
return (not command.script_parts[0] in get_all_executables()
|
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):
|
def get_new_command(command):
|
||||||
executable = _get_executable(command.script_parts[0])
|
executables = _get_executables(command.script_parts[0])
|
||||||
return command.script.replace(executable, u'{} '.format(executable), 1)
|
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
|
priority = 4000
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user