1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-21 20:38:54 +00:00

Cleanup the systemctl rule

This commit is contained in:
mcarton 2015-06-26 11:55:10 +02:00
parent e3cc9c52e6
commit 330f91f5dc

View File

@ -1,16 +1,21 @@
"""
The confusion in systemctl's param order is massive
The confusion in systemctl's param order is massive.
"""
from thefuck.utils import sudo_support
@sudo_support
def match(command, settings):
#Catches 'Unknown operation 'service'.' when executing systemctl with misordered arguments
# Catches 'Unknown operation 'service'.' when executing systemctl with
# misordered arguments
cmd = command.script.split()
return ('systemctl' in command.script) and ('Unknown operation \'' in command.stderr) and (len(cmd) - cmd.index('systemctl') == 3);
return ('systemctl' in command.script and
'Unknown operation \'' in command.stderr and
len(cmd) - cmd.index('systemctl') == 3)
@sudo_support
def get_new_command(command, settings):
cmd = command.script.split()
cmd[len(cmd)-1], cmd[len(cmd)-2] = cmd[len(cmd)-2], cmd[len(cmd)-1]
cmd[-1], cmd[-2] = cmd[-2], cmd[-1]
return ' '.join(cmd)