1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-13 22:28:33 +00:00

docker thefuck

This commit is contained in:
Bruno Borges 2015-05-05 18:13:07 -03:00
parent fb069b74d7
commit faddd741ff

23
thefuck/rules/docker.py Normal file
View File

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