From 62c824cd7df0e47fdbb98ccf9a4424a26d2a80cb Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Tue, 14 Apr 2015 00:39:36 +0000 Subject: [PATCH] Specify alternate run control file path from CLI --- features/cli/run_control.feature | 9 +++++++++ features/steps/output_steps.rb | 1 + lib/uh/wm/cli.rb | 5 +++++ spec/uh/wm/cli_spec.rb | 9 +++++++++ 4 files changed, 24 insertions(+) create mode 100644 features/cli/run_control.feature diff --git a/features/cli/run_control.feature b/features/cli/run_control.feature new file mode 100644 index 0000000..84c7832 --- /dev/null +++ b/features/cli/run_control.feature @@ -0,0 +1,9 @@ +Feature: run control file path CLI option + + Scenario: changes the path to run control file + Given a file named uhwmrc.rb with: + """ + puts 'run control evaluation' + """ + When I run uhwm with option -f uhwmrc.rb + Then the output must contain "run control evaluation" diff --git a/features/steps/output_steps.rb b/features/steps/output_steps.rb index b056e62..e55109e 100644 --- a/features/steps/output_steps.rb +++ b/features/steps/output_steps.rb @@ -6,6 +6,7 @@ options: -h, --help print this message -v, --version enable verbose mode -d, --debug enable debug mode + -f, --run-control PATH specify alternate run control file -r, --require PATH require ruby feature -l, --layout LAYOUT specify layout eoh diff --git a/lib/uh/wm/cli.rb b/lib/uh/wm/cli.rb index b11715a..8853582 100644 --- a/lib/uh/wm/cli.rb +++ b/lib/uh/wm/cli.rb @@ -64,6 +64,11 @@ module Uh @env.log_logger_level end + opts.on '-f', '--run-control PATH', + 'specify alternate run control file' do |e| + @env.rc_path = e + end + opts.on '-r', '--require PATH', 'require ruby feature' do |feature| require feature @env.log "Loaded `#{feature}' ruby feature" diff --git a/spec/uh/wm/cli_spec.rb b/spec/uh/wm/cli_spec.rb index 32a53ac..7576c4c 100644 --- a/spec/uh/wm/cli_spec.rb +++ b/spec/uh/wm/cli_spec.rb @@ -148,6 +148,15 @@ module Uh end end + context 'with run control option' do + let(:arguments) { %w[-f uhwmrc.rb] } + + it 'assigns run control file path in the env' do + cli.parse_arguments! + expect(cli.env.rc_path).to eq 'uhwmrc.rb' + end + end + context 'with require option' do let(:arguments) { %w[-r abbrev] }