Extract pipe pattern
This commit is contained in:
@@ -24,7 +24,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def stop
|
def stop
|
||||||
[ "docker ps -q #{service_filter.join(" ")} | xargs docker stop" ]
|
pipe current_container_id, "xargs docker stop"
|
||||||
end
|
end
|
||||||
|
|
||||||
def info
|
def info
|
||||||
@@ -32,9 +32,10 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def logs(lines: 1000, grep: nil)
|
def logs(lines: 1000, grep: nil)
|
||||||
[ "docker ps -q #{service_filter.join(" ")} | xargs docker logs -n #{lines} -t" ].tap do |command|
|
pipe \
|
||||||
command.first << " | grep #{grep}" if grep
|
current_container_id,
|
||||||
end
|
"xargs docker logs -n #{lines} -t",
|
||||||
|
("grep #{grep}" if grep)
|
||||||
end
|
end
|
||||||
|
|
||||||
def exec(*command, interactive: false)
|
def exec(*command, interactive: false)
|
||||||
|
|||||||
@@ -11,10 +11,15 @@ module Mrsk::Commands
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def combine(*commands)
|
def combine(*commands, by: "&&")
|
||||||
commands
|
commands
|
||||||
.collect { |command| command + [ "&&" ] }.flatten # Join commands with &&
|
.compact
|
||||||
.tap { |commands| commands.pop } # Remove trailing &&
|
.collect { |command| Array(command) + [ by ] }.flatten # Join commands
|
||||||
|
.tap { |commands| commands.pop } # Remove trailing combiner
|
||||||
|
end
|
||||||
|
|
||||||
|
def pipe(*commands)
|
||||||
|
combine *commands, by: "|"
|
||||||
end
|
end
|
||||||
|
|
||||||
def docker(*args)
|
def docker(*args)
|
||||||
|
|||||||
Reference in New Issue
Block a user