Add version CLI option
This commit is contained in:
parent
dcc41006d0
commit
71caf160be
6
features/cli/version.feature
Normal file
6
features/cli/version.feature
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Feature: version CLI option
|
||||||
|
|
||||||
|
Scenario: prints the current version on standard output
|
||||||
|
When I run uhwm with option --version
|
||||||
|
Then uhwm must terminate successfully
|
||||||
|
And the output must contain exactly the version
|
@ -10,9 +10,15 @@ options:
|
|||||||
-r, --require PATH require ruby feature
|
-r, --require PATH require ruby feature
|
||||||
-l, --layout LAYOUT specify layout
|
-l, --layout LAYOUT specify layout
|
||||||
-w, --worker WORKER specify worker
|
-w, --worker WORKER specify worker
|
||||||
|
-V, --version print version
|
||||||
eoh
|
eoh
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^the output must contain exactly the version$/ do
|
||||||
|
#require File.expand_path('../lib/uh/wm/version', __FILE__)
|
||||||
|
assert_exact_output "%s\n" % Uh::WM::VERSION, all_output
|
||||||
|
end
|
||||||
|
|
||||||
Then /^the output must match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
|
Then /^the output must match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
|
||||||
uhwm_wait_output Regexp.new(pattern, options)
|
uhwm_wait_output Regexp.new(pattern, options)
|
||||||
end
|
end
|
||||||
|
@ -82,6 +82,11 @@ module Uh
|
|||||||
'specify worker' do |worker|
|
'specify worker' do |worker|
|
||||||
@env.worker = worker.to_sym
|
@env.worker = worker.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on_tail '-V', '--version', 'print version' do
|
||||||
|
@env.puts VERSION
|
||||||
|
exit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -185,6 +185,21 @@ module Uh
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with version option' do
|
||||||
|
let(:arguments) { %w[-V] }
|
||||||
|
|
||||||
|
it 'prints the version on standard output' do
|
||||||
|
trap_exit { cli.parse_arguments! }
|
||||||
|
expect(stdout.string).to eq "#{::Uh::WM::VERSION}\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'exits with a return status of 0' do
|
||||||
|
expect { cli.parse_arguments! }.to raise_error(SystemExit) do |e|
|
||||||
|
expect(e.status).to eq 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with invalid option' do
|
context 'with invalid option' do
|
||||||
let(:arguments) { %w[--unknown-option] }
|
let(:arguments) { %w[--unknown-option] }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user