Skip to content

Commit

Permalink
Add command line help
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwilk committed Apr 8, 2010
1 parent 9e72a54 commit 8de7937
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
15 changes: 15 additions & 0 deletions features/help.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Feature: Showing help
In order to harness the full power of cucover
As a developer
I want to see help explaining cucovers usage

Background:
Given I am using the simple example app

Scenario: --help
When I run cucover --help
Then I should see "Usage: cucover -- [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+"

Scenario: invalid command line handle
When I run cucover --invalid-thingy
Then I should see "Usage: cucover -- [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+"
7 changes: 6 additions & 1 deletion features/step_definitions/main_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@
end

strip_trailing_spaces(strip_duration(@out)).should == expected_text
end
end

Then /^I should see "([^\"]*)"$/ do |expected_text|
@out.should =~ /#{Regexp.escape(expected_text)}/
end

32 changes: 27 additions & 5 deletions lib/cucover/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,40 @@ def start
private

def command_type
if @args.index('--')
case @args.first
when '--'
CliCommands::Cucumber
elsif @args.index('--version')
when '--version', '-v'
CliCommands::Version
elsif @args.index('--coverage-of')
when '--coverage-of', '-c'
CliCommands::CoverageOf
elsif @args.index('--show-recordings')
when '--show-recordings', '-s'
CliCommands::ShowRecordings
else
raise("Sorry: I don't understand these command line arguments: #{@args.inspect}. Soon I will say something more helpful here.")
puts help
Kernel.exit(0)
end
end

def help
<<-EOH
Usage: cucover -- [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+
Examples:
cucover -- --format pretty features
cucover --coverage-of lib/monkeys.rb
cucover --show-recordings
-- [ARGS] Run cucumber while recording coverage. This will skip scenarios
if they have already been run and the covering code has not
been changed.
-c [FILE], --coverage-of [FILE] Show file with feature coverage information
-s, --show-recordings Show all coverage information currently recorded
-v, --version Show version
-h, --help You're looking at it.
EOH
end

end
end

0 comments on commit 8de7937

Please sign in to comment.