diff --git a/lib/compass/commands/help.rb b/lib/compass/commands/help.rb index c233a1e4..1fc69760 100644 --- a/lib/compass/commands/help.rb +++ b/lib/compass/commands/help.rb @@ -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 diff --git a/lib/compass/commands/list_frameworks.rb b/lib/compass/commands/list_frameworks.rb index 3e1e05f8..bc8b2fdc 100644 --- a/lib/compass/commands/list_frameworks.rb +++ b/lib/compass/commands/list_frameworks.rb @@ -8,8 +8,13 @@ module Compass end def execute - Compass::Frameworks::ALL.each do |framework| - puts framework.name unless framework.name =~ /^_/ + 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 diff --git a/lib/compass/frameworks.rb b/lib/compass/frameworks.rb index 57e9bcd6..39faadff 100644 --- a/lib/compass/frameworks.rb +++ b/lib/compass/frameworks.rb @@ -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