[Command Line] Primary commands get special status in the initial help output.
This commit is contained in:
parent
46ccb5b6e1
commit
a281dc1d5f
@ -129,16 +129,23 @@ Feature: Command Line
|
|||||||
And an image file images/buttons/tick.png is created
|
And an image file images/buttons/tick.png is created
|
||||||
And a css file tmp/buttons.css is created
|
And a css file tmp/buttons.css is created
|
||||||
|
|
||||||
|
@now
|
||||||
Scenario: Basic help
|
Scenario: Basic help
|
||||||
When I run: compass help
|
When I run: compass help
|
||||||
Then I should be shown a list of available commands
|
Then I should see the following "primary" commands:
|
||||||
And the list of commands should describe the compile command
|
| compile |
|
||||||
And the list of commands should describe the create command
|
| create |
|
||||||
And the list of commands should describe the grid-img command
|
| init |
|
||||||
And the list of commands should describe the help command
|
| watch |
|
||||||
And the list of commands should describe the init command
|
And I should see the following "other" commands:
|
||||||
And the list of commands should describe the install command
|
| config |
|
||||||
And the list of commands should describe the version command
|
| grid-img |
|
||||||
|
| help |
|
||||||
|
| install |
|
||||||
|
| interactive |
|
||||||
|
| stats |
|
||||||
|
| validate |
|
||||||
|
| version |
|
||||||
|
|
||||||
Scenario: Recompiling a project with no material changes
|
Scenario: Recompiling a project with no material changes
|
||||||
Given I am using the existing project in test/fixtures/stylesheets/compass
|
Given I am using the existing project in test/fixtures/stylesheets/compass
|
||||||
|
@ -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:/
|
@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
|
end
|
||||||
|
|
||||||
Then /^I should be shown a list of available commands$/ do
|
Then /^I should be shown a list of "([^"]+)" commands$/ do |kind|
|
||||||
@last_result.should =~ /^Available commands:$/
|
@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
|
end
|
||||||
|
|
||||||
Then /^the list of commands should describe the ([^ ]+) command$/ do |command|
|
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
|
||||||
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
|
||||||
|
@ -68,6 +68,8 @@ module Compass
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def primary; true; end
|
||||||
|
|
||||||
def parse!(arguments)
|
def parse!(arguments)
|
||||||
parser = option_parser(arguments)
|
parser = option_parser(arguments)
|
||||||
parse_options!(parser, arguments)
|
parse_options!(parser, arguments)
|
||||||
|
@ -11,16 +11,16 @@ Description:
|
|||||||
|
|
||||||
To get help on a particular command please specify the command.
|
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}"
|
primary_commands = Compass::Commands.all.select do |c|
|
||||||
if Compass::Commands[command].respond_to? :description
|
cmd = Compass::Commands[c]
|
||||||
banner << "\t- #{Compass::Commands[command].description(command)}"
|
cmd.respond_to?(:primary) && cmd.primary
|
||||||
end
|
|
||||||
banner << "\n"
|
|
||||||
end
|
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"
|
banner << "\nAvailable Frameworks & Patterns:\n\n"
|
||||||
Compass::Frameworks::ALL.each do |framework|
|
Compass::Frameworks::ALL.each do |framework|
|
||||||
@ -38,6 +38,18 @@ Available commands:
|
|||||||
|
|
||||||
super
|
super
|
||||||
end
|
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
|
end
|
||||||
class Help < Base
|
class Help < Base
|
||||||
register :help
|
register :help
|
||||||
|
@ -136,6 +136,8 @@ module Compass
|
|||||||
"Report statistics about your stylesheets"
|
"Report statistics about your stylesheets"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def primary; false; end
|
||||||
|
|
||||||
def parse!(arguments)
|
def parse!(arguments)
|
||||||
parser = option_parser(arguments)
|
parser = option_parser(arguments)
|
||||||
parser.parse!
|
parser.parse!
|
||||||
|
@ -62,6 +62,8 @@ module Compass
|
|||||||
option_parser([]).to_s
|
option_parser([]).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def primary; true; end
|
||||||
|
|
||||||
def description(command)
|
def description(command)
|
||||||
"Compile Sass stylesheets to CSS"
|
"Compile Sass stylesheets to CSS"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user