diff --git a/lib/mrsk/cli/base.rb b/lib/mrsk/cli/base.rb index ede29a5c..ee1851bf 100644 --- a/lib/mrsk/cli/base.rb +++ b/lib/mrsk/cli/base.rb @@ -27,7 +27,7 @@ module Mrsk::Cli def initialize(*) super load_envs - initialize_commander(options) + initialize_commander(options_with_subcommand_class_options) end private @@ -39,6 +39,10 @@ module Mrsk::Cli end end + def options_with_subcommand_class_options + options.merge(@_initializer.last[:class_options] || {}) + end + def initialize_commander(options) MRSK.tap do |commander| if options[:verbose] diff --git a/test/cli/app_test.rb b/test/cli/app_test.rb index 41d7ffd0..2dc5ad64 100644 --- a/test/cli/app_test.rb +++ b/test/cli/app_test.rb @@ -121,6 +121,13 @@ class CliAppTest < CliTestCase end end + + test "version through main" do + stdouted { Mrsk::Cli::Main.start(["app", "version", "-c", "test/fixtures/deploy_with_accessories.yml", "--hosts", "1.1.1.1"]) }.tap do |output| + assert_match "docker ps --filter label=service=app --format \"{{.Names}}\" | sed 's/-/\\n/g' | tail -n 1", output + end + end + private def run_command(*command) stdouted { Mrsk::Cli::App.start([*command, "-c", "test/fixtures/deploy_with_accessories.yml", "--hosts", "1.1.1.1"]) }