Move argumentize to Utils

This commit is contained in:
David Heinemeier Hansson
2023-01-20 10:26:36 +01:00
parent 454015b294
commit 9bb1fb7166
4 changed files with 9 additions and 8 deletions

View File

@@ -1,6 +1,11 @@
module Mrsk::Utils
extend self
# Return a list of shell arguments using the same named argument against the passed attributes.
def argumentize(argument, attributes, redacted: false)
attributes.flat_map { |k, v| [ argument, redacted ? redact("#{k}=#{v}") : "#{k}=#{v}" ] }
end
# Copied from SSHKit::Backend::Abstract#redact to be available inside Commands classes
def redact(arg) # Used in execute_command to hide redact() args a user passes in
arg.to_s.extend(SSHKit::Redaction) # to_s due to our inability to extend Integer, etc