diff --git a/features/command_line.feature b/features/command_line.feature index 800c2253..f6e6ae9e 100644 --- a/features/command_line.feature +++ b/features/command_line.feature @@ -129,16 +129,23 @@ Feature: Command Line And an image file images/buttons/tick.png is created And a css file tmp/buttons.css is created + @now Scenario: Basic help When I run: compass help - Then I should be shown a list of available commands - And the list of commands should describe the compile command - And the list of commands should describe the create command - And the list of commands should describe the grid-img command - And the list of commands should describe the help command - And the list of commands should describe the init command - And the list of commands should describe the install command - And the list of commands should describe the version command + Then I should see the following "primary" commands: + | compile | + | create | + | init | + | watch | + And I should see the following "other" commands: + | config | + | grid-img | + | help | + | install | + | interactive | + | stats | + | validate | + | version | Scenario: Recompiling a project with no material changes Given I am using the existing project in test/fixtures/stylesheets/compass diff --git a/features/step_definitions/command_line_steps.rb b/features/step_definitions/command_line_steps.rb index 4d8c86ae..4f8e8854 100644 --- a/features/step_definitions/command_line_steps.rb +++ b/features/step_definitions/command_line_steps.rb @@ -160,8 +160,21 @@ Then /^I am told how to compile my sass stylesheets$/ do @last_result.should =~ /You must compile your sass stylesheets into CSS when they change.\nThis can be done in one of the following ways:/ end -Then /^I should be shown a list of available commands$/ do - @last_result.should =~ /^Available commands:$/ +Then /^I should be shown a list of "([^"]+)" commands$/ do |kind| + @last_result.should =~ /^#{kind.capitalize} Commands:$/ + @last_command_list = [] + found = false + indent = nil + @last_result.split("\n").each do |line| + if line =~ /^#{kind.capitalize} Commands:$/ + found = true + elsif found && line =~ /^\s+/ + @last_command_list << line + elsif found && line =~ /^$|^\w/ + break + end + end + end Then /^the list of commands should describe the ([^ ]+) command$/ do |command| @@ -196,4 +209,11 @@ Then /^I am told statistics for each file:$/ do |table| end end +Then /^I should see the following "([^"]+)" commands:$/ do |kind, table| + + Then %Q{I should be shown a list of "#{kind}" commands} + + commands = @last_command_list.map{|c| c =~ /^\s+\* ([^ ]+)\s+- [A-Z].+$/; [$1]} + table.diff!(commands) +end diff --git a/lib/compass/commands/create_project.rb b/lib/compass/commands/create_project.rb index ca0f0330..fa3d2dbe 100644 --- a/lib/compass/commands/create_project.rb +++ b/lib/compass/commands/create_project.rb @@ -68,6 +68,8 @@ module Compass end end + def primary; true; end + def parse!(arguments) parser = option_parser(arguments) parse_options!(parser, arguments) diff --git a/lib/compass/commands/help.rb b/lib/compass/commands/help.rb index dccc313e..2f5067e2 100644 --- a/lib/compass/commands/help.rb +++ b/lib/compass/commands/help.rb @@ -11,16 +11,16 @@ Description: To get help on a particular command please specify the command. -Available commands: - } - Compass::Commands.all.sort_by{|c| c.to_s}.each do |command| - banner << " * #{command}" - if Compass::Commands[command].respond_to? :description - banner << "\t- #{Compass::Commands[command].description(command)}" - end - banner << "\n" + + primary_commands = Compass::Commands.all.select do |c| + cmd = Compass::Commands[c] + cmd.respond_to?(:primary) && cmd.primary end + other_commands = Compass::Commands.all - primary_commands + + banner << command_list("Primary Commands:", primary_commands) + banner << command_list("Other Commands:", other_commands) banner << "\nAvailable Frameworks & Patterns:\n\n" Compass::Frameworks::ALL.each do |framework| @@ -38,6 +38,18 @@ Available commands: super end + + def command_list(header, commands) + list = "#{header}\n" + commands.sort_by{|c| c.to_s}.each do |command| + list << " * #{command}" + if Compass::Commands[command].respond_to? :description + list << "\t- #{Compass::Commands[command].description(command)}" + end + list << "\n" + end + list + end end class Help < Base register :help diff --git a/lib/compass/commands/project_stats.rb b/lib/compass/commands/project_stats.rb index 05d20acf..81f958c9 100644 --- a/lib/compass/commands/project_stats.rb +++ b/lib/compass/commands/project_stats.rb @@ -136,6 +136,8 @@ module Compass "Report statistics about your stylesheets" end + def primary; false; end + def parse!(arguments) parser = option_parser(arguments) parser.parse! diff --git a/lib/compass/commands/update_project.rb b/lib/compass/commands/update_project.rb index 0f49ff33..9ab8814b 100644 --- a/lib/compass/commands/update_project.rb +++ b/lib/compass/commands/update_project.rb @@ -62,6 +62,8 @@ module Compass option_parser([]).to_s end + def primary; true; end + def description(command) "Compile Sass stylesheets to CSS" end