Operate accessories

When you want mysql, redis, and the like under MRSK management
This commit is contained in:
David Heinemeier Hansson
2023-01-22 16:52:57 +01:00
parent 48f8f7cb57
commit 6b98eb3677
13 changed files with 453 additions and 3 deletions

View File

@@ -1,9 +1,15 @@
module Mrsk::Utils
extend self
# Return a list of shell arguments using the same named argument against the passed attributes.
# Return a list of shell arguments using the same named argument against the passed attributes (hash or array).
def argumentize(argument, attributes, redacted: false)
Array(attributes).flat_map { |k, v| [ argument, redacted ? redact("#{k}=#{v}") : "#{k}=#{v}" ] }
Array(attributes).flat_map do |k, v|
if v.present?
[ argument, redacted ? redact("#{k}=#{v}") : "#{k}=#{v}" ]
else
[ argument, k ]
end
end
end
# Return a list of shell arguments using the same named argument against the passed attributes,