Implement basic CLI usage help

This commit is contained in:
Thibault Jouan
2015-04-07 17:34:16 +00:00
parent f38a5761be
commit 422a940eae
6 changed files with 184 additions and 10 deletions

View File

@@ -0,0 +1,11 @@
Feature: CLI usage
Scenario: prints the usage when unknown option switch is given
When I run uhwm with option --unknown-option
Then the exit status must be 64
And the output must contain exactly the usage
Scenario: prints the help when -h option is given
When I run uhwm with option -h
Then the exit status must be 0
And the output must contain exactly the usage

View File

@@ -0,0 +1,8 @@
Then /^the output must contain exactly the usage$/ do
assert_exact_output <<-eoh, all_output
Usage: uhwm [options]
options:
-h, --help print this message
eoh
end

View File

@@ -1,4 +1,17 @@
When /^I start uhwm$/ do
@process = run 'uhwm'
@interactive = @process
def uhwm_run options = nil
command = %w[uhwm]
command << options if options
@interactive = @process = run command.join ' '
end
When /^I start uhwm$/ do
uhwm_run
end
When /^I run uhwm with options? (-.+)$/ do |options|
uhwm_run options
end
Then /^the exit status must be (\d+)$/ do |exit_status|
assert_exit_status exit_status.to_i
end