Add a command line option to print out the value of a particular configuration value.

This commit is contained in:
Chris Eppstein 2010-10-25 17:52:13 -07:00
parent 8a59e34ec8
commit a8cf0beadc
3 changed files with 35 additions and 2 deletions

View File

@ -247,6 +247,23 @@ Feature: Command Line
| sass_dir | sass |
| css_dir | assets/css |
@now
Scenario Outline: Print out a configuration value
Given I am using the existing project in test/fixtures/stylesheets/compass
When I run: compass config -p <property>
Then I should see the following output: <value>
And the command exits <exit>
Examples:
| property | value | exit |
| extensions_dir | extensions | normally |
| extensions_path | $PROJECT_PATH/extensions | normally |
| css_dir | tmp | normally |
| css_path | $PROJECT_PATH/tmp | normally |
| sass_dir | sass | normally |
| sass_path | $PROJECT_PATH/sass | normally |
| foobar | ERROR: configuration property 'foobar' does not exist | with a non-zero error code |
Scenario: Validate the generated CSS
Given I am using the existing project in test/fixtures/stylesheets/compass
When I run: compass validate

View File

@ -155,6 +155,9 @@ Then /^the command exits with a non\-zero error code$/ do
@last_exit_code.should_not == 0
end
Then /^the command exits normally$/ do
@last_exit_code.should == 0
end
Then /^I am congratulated$/ do
@last_result.should =~ /Congratulations!/
@ -235,3 +238,8 @@ end
Then /^I should see the following lines of output:$/ do |table|
table.diff!([['blueprint'],['compass']])
end
Then /^I should see the following output: (.+)$/ do |expected|
(@last_result.strip + @last_error.strip).should == expected.gsub(/\$PROJECT_PATH/,Dir.pwd).strip
end

View File

@ -20,7 +20,9 @@ module Compass
opts.on("--debug [PROPERTY]", "Debug your configuration by printing out details.") do |prop|
self.options[:debug] = prop.nil? ? true : prop.to_sym
end
opts.on("-p PROPERTY", "--property PROPERTY", "Print out the value of the given property") do |prop|
self.options[:display] = prop.to_sym
end
super
end
end
@ -40,7 +42,13 @@ module Compass
end
def perform
if options[:debug]
if options[:display]
if Compass.configuration.respond_to?(options[:display])
puts Compass.configuration.send(options[:display])
else
raise Compass::Error, %Q{ERROR: configuration property '#{options[:display]}' does not exist}
end
elsif options[:debug]
puts "Configuration sources:"
c = Compass.configuration
while c