From c668f2aed25485874cd4abb0ca90fd2c7c95f92a Mon Sep 17 00:00:00 2001 From: Lovro Bikic Date: Sun, 9 Jan 2022 12:37:41 +0100 Subject: [PATCH 1/2] Refactor sort_options method and add tests --- lib/mina/application.rb | 10 +++++----- spec/lib/mina/application_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/mina/application.rb b/lib/mina/application.rb index 7d08864a..5440a52b 100644 --- a/lib/mina/application.rb +++ b/lib/mina/application.rb @@ -21,12 +21,12 @@ def run(*args) # :nocov: def sort_options(options) - not_applicable_to_mina = ['quiet', 'silent', 'verbose', 'dry-run'] - options.reject! do |(switch, *)| - switch =~ /--#{Regexp.union(not_applicable_to_mina)}/ - end + options_not_applicable_to_mina = /--#{Regexp.union(['quiet', 'silent', 'verbose', 'dry-run'])}/ - super.push(version, verbose, simulate, debug_configuration_variables, no_report_time) + mina_options = options.reject { |(switch, *)| switch =~ options_not_applicable_to_mina } + mina_options += [version, verbose, simulate, debug_configuration_variables, no_report_time] + + super(mina_options) end def top_level_tasks diff --git a/spec/lib/mina/application_spec.rb b/spec/lib/mina/application_spec.rb index 6483c606..b3a7d40f 100644 --- a/spec/lib/mina/application_spec.rb +++ b/spec/lib/mina/application_spec.rb @@ -75,4 +75,24 @@ end end end + + describe 'Rake options' do + let(:options) { application.standard_rake_options } + + it 'shows --verbose' do + expect(options.any? { |(switch, *)| switch == '--verbose' }).to eq(true) + end + + it "doesn't show --dry-run" do + expect(options.any? { |(switch, *)| switch == '--dry-run' }).to eq(false) + end + + it "doesn't show --quiet" do + expect(options.any? { |(switch, *)| switch == '--quiet' }).to eq(false) + end + + it "doesn't show --silent" do + expect(options.any? { |(switch, *)| switch == '--silent' }).to eq(false) + end + end end From f47c3661c7ab278ba16d927dbed83b9349e138d8 Mon Sep 17 00:00:00 2001 From: Lovro Bikic Date: Sun, 9 Jan 2022 12:39:11 +0100 Subject: [PATCH 2/2] Update Mina CLI options descriptions --- lib/mina/application.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mina/application.rb b/lib/mina/application.rb index 5440a52b..12f8f294 100644 --- a/lib/mina/application.rb +++ b/lib/mina/application.rb @@ -56,7 +56,7 @@ def version def verbose [ '--verbose', '-v', - 'Print more info', + 'Print a command before its execution.', lambda do |_value| set(:verbose, true) end @@ -66,7 +66,7 @@ def verbose def simulate [ '--simulate', '-s', - 'Do a simulate run without executing actions', + 'Run a simulation. All commands will be printed but not executed.', lambda do |_value| set(:simulate, true) end @@ -76,7 +76,7 @@ def simulate def debug_configuration_variables [ '--debug-configuration-variables', '-d', - 'Display the defined config variables before runnig the tasks.', + 'Display configuration variables.', lambda do |_value| set(:debug_configuration_variables, true) end @@ -86,7 +86,7 @@ def debug_configuration_variables def no_report_time [ '--no-report-time', nil, - 'Skip time reporting', + "Don't report execution time.", lambda do |_value| set(:skip_report_time, true) end