From d263b0ffa53ac60b0271a0c59f77a84947404d6c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 3 Feb 2023 16:27:10 +0100 Subject: [PATCH] Extract xargs helper --- lib/mrsk/commands/app.rb | 4 ++-- lib/mrsk/commands/base.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/mrsk/commands/app.rb b/lib/mrsk/commands/app.rb index 45012d9f..7a04c7bd 100644 --- a/lib/mrsk/commands/app.rb +++ b/lib/mrsk/commands/app.rb @@ -28,7 +28,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base end def stop - pipe current_container_id, "xargs docker stop" + pipe current_container_id, xargs(docker(:stop)) end def info @@ -83,7 +83,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base def remove_container(version:) pipe \ container_id_for(container_name: service_with_version(version)), - [ "xargs", docker(:container, :rm) ].flatten + xargs(docker(:container, :rm)) end def remove_containers diff --git a/lib/mrsk/commands/base.rb b/lib/mrsk/commands/base.rb index 49a8bf81..44c1807f 100644 --- a/lib/mrsk/commands/base.rb +++ b/lib/mrsk/commands/base.rb @@ -28,6 +28,10 @@ module Mrsk::Commands combine *commands, by: "|" end + def xargs(command) + [ :xargs, command ].flatten + end + def docker(*args) args.compact.unshift :docker end