1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 14:48:49 +00:00

add docker container removal

This commit is contained in:
Connor Martin 2019-07-05 13:50:28 -05:00
parent 4c3a559124
commit dac27923bd
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,15 @@
from thefuck.rules.docker_image_being_used_by_container import match, get_new_command
from thefuck.types import Command
def test_match():
err_response = """
Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image
is being used by running container e5e2591040d1
"""
assert match(Command('docker image rm -f cd809b04b6ff', err_response))
def test_get_new_command():
assert get_new_command(Command('docker image rm -f cd809b04b6ff',
'')) == 'docker container rm -f e5e2591040d1 && docker image rm -f cd809b04b6ff'

View File

@ -0,0 +1,11 @@
from thefuck.utils import for_app, replace_command
@for_app('docker')
def match(command):
return 'image is being used by running container' in command.output
def get_new_command(command):
container_id = command.output.split(' ')[-1]
return 'docker container rm -f {} && {}'.format(container_id, command.script)