Specify alternate run control file path from CLI

This commit is contained in:
Thibault Jouan 2015-04-14 00:39:36 +00:00
parent 7493ab3284
commit 62c824cd7d
4 changed files with 24 additions and 0 deletions

View File

@ -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"

View File

@ -6,6 +6,7 @@ options:
-h, --help print this message -h, --help print this message
-v, --version enable verbose mode -v, --version enable verbose mode
-d, --debug enable debug mode -d, --debug enable debug mode
-f, --run-control PATH specify alternate run control file
-r, --require PATH require ruby feature -r, --require PATH require ruby feature
-l, --layout LAYOUT specify layout -l, --layout LAYOUT specify layout
eoh eoh

View File

@ -64,6 +64,11 @@ module Uh
@env.log_logger_level @env.log_logger_level
end 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| opts.on '-r', '--require PATH', 'require ruby feature' do |feature|
require feature require feature
@env.log "Loaded `#{feature}' ruby feature" @env.log "Loaded `#{feature}' ruby feature"

View File

@ -148,6 +148,15 @@ module Uh
end end
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 context 'with require option' do
let(:arguments) { %w[-r abbrev] } let(:arguments) { %w[-r abbrev] }