Global option for designating primary host only

This commit is contained in:
David Heinemeier Hansson
2023-01-20 17:18:32 +01:00
parent 79b5ed179e
commit 31389bc7b5
7 changed files with 49 additions and 43 deletions

View File

@@ -9,6 +9,7 @@ module Mrsk::Cli
class_option :verbose, type: :boolean, aliases: "-v", desc: "Detailed logging"
class_option :primary, type: :boolean, aliases: "-p", desc: "Run commands only on primary host instead of all"
class_option :hosts, aliases: "-h", desc: "Run commands on these hosts instead of all (separate by comma)"
class_option :roles, aliases: "-r", desc: "Run commands on these roles instead of all (separate by comma)"
@@ -25,9 +26,11 @@ module Mrsk::Cli
MRSK.tap do |commander|
commander.config_file = Pathname.new(File.expand_path(options[:config_file]))
commander.destination = options[:destination]
commander.hosts = options[:hosts]&.split(",")
commander.roles = options[:roles]&.split(",")
commander.verbose = options[:verbose]
commander.specific_hosts = options[:hosts]&.split(",")
commander.specific_roles = options[:roles]&.split(",")
commander.specific_primary! if options[:primary]
end
end