Merge pull request #264 from mcarton/cleanup

Cleanup
This commit is contained in:
Vladimir Iakovlev
2015-06-26 17:30:14 +03:00
16 changed files with 102 additions and 96 deletions
+4 -1
View File
@@ -1,3 +1,6 @@
from thefuck import shells
def match(command, settings):
return ('git' in command.script
and 'pull' in command.script
@@ -9,4 +12,4 @@ def get_new_command(command, settings):
branch = line.split(' ')[-1]
set_upstream = line.replace('<remote>', 'origin')\
.replace('<branch>', branch)
return u'{} && {}'.format(set_upstream, command.script)
return shells.and_(set_upstream, command.script)
+6 -5
View File
@@ -1,13 +1,14 @@
# Fixes common java command mistake
#
#
# Example:
# > java foo.java
# Error: Could not find or load main class foo.java
#
def match(command, settings):
return (command.script.startswith ('java ')
and command.script.endswith ('.java'))
return (command.script.startswith('java ')
and command.script.endswith('.java'))
def get_new_command(command, settings):
return command.script[:-5]
return command.script[:-5]
+7 -7
View File
@@ -1,15 +1,15 @@
# Appends .java when compiling java files
#
#
# Example:
# > javac foo
# error: Class names, 'foo', are only accepted if annotation
# error: Class names, 'foo', are only accepted if annotation
# processing is explicitly requested
#
#
def match(command, settings):
return (command.script.startswith ('javac ')
and not command.script.endswith('.java'))
return (command.script.startswith('javac ')
and not command.script.endswith('.java'))
def get_new_command(command, settings):
return command.script + '.java'
return command.script + '.java'
-15
View File
@@ -1,15 +0,0 @@
# Appends .py when compiling python files
#
# Example:
# > python foo
# error: python: can't open file 'foo': [Errno 2] No such file or directory
#
#
def match(command, settings):
return (command.script.startswith ('python ')
and not command.script.endswith('.py'))
def get_new_command(command, settings):
return command.script + '.py'
+14
View File
@@ -0,0 +1,14 @@
# Appends .py when executing python files
#
# Example:
# > python foo
# error: python: can't open file 'foo': [Errno 2] No such file or directory
def match(command, settings):
return (command.script.startswith('python ')
and not command.script.endswith('.py'))
def get_new_command(command, settings):
return command.script + '.py'
-2
View File
@@ -7,14 +7,12 @@ patterns = ['permission denied',
'root privilege',
'This command has to be run under the root user.',
'This operation requires root.',
'You need to be root to perform this command.',
'requested operation requires superuser privilege',
'must be run as root',
'must be superuser',
'must be root',
'need to be root',
'need root',
'you must be root to run this program.',
'only root can do that']
+9 -4
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)