1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-20 01:28:56 +00:00
This commit is contained in:
Bruno Borges 2015-05-05 18:20:33 -03:00
parent faddd741ff
commit acb901a6d9

View File

@ -1,23 +1,14 @@
try: patterns = ['FATA[0000]',
import CommandNotFound ]
except ImportError:
enabled_by_default = False
def match(command, settings): def match(command, settings):
if 'not found' in command.stderr: for pattern in patterns:
try: if pattern.lower() in command.stderr.lower()\
c = CommandNotFound.CommandNotFound() or pattern.lower() in command.stdout.lower():
pkgs = c.getPackages(command.script.split(" ")[0])
name, _ = pkgs[0]
return True return True
except IndexError: return False
# IndexError is thrown when no matching package is found
return False
def get_new_command(command, settings): def get_new_command(command, settings):
c = CommandNotFound.CommandNotFound() return u'sudo {}'.format(command.script)
pkgs = c.getPackages(command.script.split(" ")[0])
name, _ = pkgs[0]
return "sudo docker {} && {}".format(name, command.script)