#579: Add missing_space_before_subcommand rule

This commit is contained in:
Vladimir Iakovlev
2017-03-13 22:21:34 +01:00
parent 14a9cd85aa
commit 2315929875
3 changed files with 58 additions and 0 deletions
@@ -0,0 +1,18 @@
from thefuck.utils import get_all_executables, memoize, which
@memoize
def _get_executable(script_part):
for executable in get_all_executables():
if script_part.startswith(executable):
return executable
def match(command):
return (not which(command.script_parts[0])
and _get_executable(command.script_parts[0]))
def get_new_command(command):
executable = _get_executable(command.script_parts[0])
return command.script.replace(executable, u'{} '.format(executable), 1)