Extract xargs helper

This commit is contained in:
David Heinemeier Hansson
2023-02-03 16:27:10 +01:00
parent 3c1053fedd
commit d263b0ffa5
2 changed files with 6 additions and 2 deletions

View File

@@ -28,7 +28,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
end end
def stop def stop
pipe current_container_id, "xargs docker stop" pipe current_container_id, xargs(docker(:stop))
end end
def info def info
@@ -83,7 +83,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
def remove_container(version:) def remove_container(version:)
pipe \ pipe \
container_id_for(container_name: service_with_version(version)), container_id_for(container_name: service_with_version(version)),
[ "xargs", docker(:container, :rm) ].flatten xargs(docker(:container, :rm))
end end
def remove_containers def remove_containers

View File

@@ -28,6 +28,10 @@ module Mrsk::Commands
combine *commands, by: "|" combine *commands, by: "|"
end end
def xargs(command)
[ :xargs, command ].flatten
end
def docker(*args) def docker(*args)
args.compact.unshift :docker args.compact.unshift :docker
end end