From 341979d937a30158940aa4f543eaf0cc01995982 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sat, 23 Aug 2008 17:18:45 -0700 Subject: [PATCH] cleanup command line processing of primary command --- lib/compass/exec.rb | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/compass/exec.rb b/lib/compass/exec.rb index 66e65790..fc9fd684 100644 --- a/lib/compass/exec.rb +++ b/lib/compass/exec.rb @@ -39,12 +39,8 @@ module Compass protected def perform! - if options[:version] - do_command(:print_version) - elsif options[:update] - do_command(:update_project) - elsif options[:project_name] - do_command(:create_project) + if options[:command] + do_command(options[:command]) else puts self.opts end @@ -56,6 +52,7 @@ module Compass if ARGV.size > 0 self.options[:project_name] = ARGV.shift end + self.options[:command] ||= self.options[:project_name] ? :create_project : :update_project self.options[:environment] ||= :production self.options[:framework] ||= :compass end @@ -73,18 +70,14 @@ Description: Options: END opts.on('-u', '--update', :NONE, 'Update the current project') do - self.options[:update] = true + self.options[:command] = :update_project end opts.on('-f FRAMEWORK', '--framework FRAMEWORK', [:compass, :blueprint], 'Set up a new project using the selected framework. Legal values: compass (default), blueprint') do |framework| self.options[:framework] = framework end - opts.on('--force', :NONE, 'Force. Allows some commands to succeed when they would otherwise fail.') do - self.options[:force] = true - end - - opts.on('-e ENV', '--environment ENV', [:development, :production], 'Use sensible defaults for your current environment (development, production)') do |env| + opts.on('-e ENV', '--environment ENV', [:development, :production], 'Use sensible defaults for your current environment: development, production (default)') do |env| self.options[:environment] = env end @@ -104,13 +97,17 @@ END self.options[:trace] = true end + opts.on('--force', :NONE, 'Force. Allows some commands to succeed when they would otherwise fail.') do + self.options[:force] = true + end + opts.on_tail("-?", "-h", "--help", "Show this message") do puts opts exit end opts.on_tail("-v", "--version", "Print version") do - self.options[:version] = true + self.options[:command] = :print_version end end