mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-13 22:28:33 +00:00
docker thefuck
This commit is contained in:
parent
fb069b74d7
commit
faddd741ff
23
thefuck/rules/docker.py
Normal file
23
thefuck/rules/docker.py
Normal 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)
|
Loading…
x
Reference in New Issue
Block a user