[Command Line] The compass frameworks command has nicer output now -- similar to compass help. The -q option can be used to get a simple list of frameworks.

This commit is contained in:
Chris Eppstein 2010-05-30 10:59:39 -07:00
parent 6ab85ecd83
commit 8889d25414
3 changed files with 29 additions and 13 deletions

View File

@ -23,17 +23,7 @@ To get help on a particular command please specify the command.
banner << command_list("Other Commands:", other_commands)
banner << "\nAvailable Frameworks & Patterns:\n\n"
Compass::Frameworks::ALL.each do |framework|
next if framework.name =~ /^_/
banner << " * #{framework.name}\n"
framework.template_directories.each do |pattern|
banner << " - #{framework.name}/#{pattern}"
if description = framework.manifest(pattern).description
banner << "\t- #{description}"
end
banner << "\n"
end
end
banner << Compass::Frameworks.pretty_print
banner << "\nGlobal Options:\n"
opts.banner = banner

View File

@ -8,9 +8,14 @@ module Compass
end
def execute
if options[:quiet]
Compass::Frameworks::ALL.each do |framework|
puts framework.name unless framework.name =~ /^_/
end
else
puts "Available Frameworks & Patterns:\n\n"
puts Compass::Frameworks.pretty_print
end
end
class << self
def option_parser(arguments)

View File

@ -97,6 +97,27 @@ module Compass
end
end
def pretty_print
result = ""
max = Compass::Frameworks::ALL.inject(0) do |gm, framework|
fm = framework.template_directories.inject(0) do |lm,pattern|
[lm, 7 + framework.name.size + pattern.size].max
end
[gm, fm].max
end
Compass::Frameworks::ALL.each do |framework|
next if framework.name =~ /^_/
result << " * #{framework.name}\n"
framework.template_directories.each do |pattern|
result << " - #{framework.name}/#{pattern}".ljust(max)
if description = framework.manifest(pattern).description
result << " - #{description}"
end
result << "\n"
end
end
result
end
end
end