lib/shuttle/cli.rb in shuttle-deploy-0.2.0.beta7 vs lib/shuttle/cli.rb in shuttle-deploy-0.2.0.beta9

- old
+ new

@@ -3,25 +3,38 @@ module Shuttle class CLI attr_reader :options, :command attr_reader :path + def self.run + Shuttle::CLI.new.run + end + def initialize(path=nil) @path = File.expand_path(path || Dir.pwd) @options = default_options end def run parse_options parse_command - find_config - begin - runner = Shuttle::Runner.new(@options) - runner.execute(@command.dup) - rescue Shuttle::ConfigError => err - terminate(err.message) + if @command == 'generate' + begin + generator = Shuttle::Generator.new.run + rescue Exception => err + terminate(err.message) + end + else + find_config + + begin + runner = Shuttle::Runner.new(@options) + runner.execute(@command.dup) + rescue Shuttle::ConfigError => err + terminate(err.message) + end end end def terminate(message, status=1) STDERR.puts(message) @@ -96,13 +109,14 @@ private def lookup_files [ + options[:path], "#{@path}/shuttle.yml", "#{@path}/config/deploy.yml", "#{@path}/config/deploy/#{options[:target]}.yml", "#{ENV['HOME']}/.shuttle/#{File.basename(Dir.pwd)}.yml" - ] + ].compact end end end \ No newline at end of file