bin/ridgepole in ridgepole-0.4.6 vs bin/ridgepole in ridgepole-0.4.7

- old
+ new

@@ -3,18 +3,20 @@ require 'rubygems' require 'yaml' require 'optparse' require 'fileutils' require 'ridgepole' +require 'ridgepole/cli/config' $stdout.sync = true $stderr.sync = true Version = Ridgepole::VERSION DEFAULT_FILENAME = 'Schemafile' config = nil +env = 'development' mode = nil file = DEFAULT_FILENAME output_file = '-' split = false diff_files = nil @@ -40,10 +42,11 @@ end ARGV.options do |opt| begin opt.on('-c', '--config CONF_OR_FILE') {|v| config = v } + opt.on('-E', '--env ENVIRONMENT') {|v| env = v } opt.on('-a', '--apply') { set_mode[:apply] } opt.on('-m', '--merge') { set_mode[:apply]; options[:merge] = true } opt.on('-f', '--file FILE') {|v| file = v } opt.on('', '--dry-run') { options[:dry_run] = true } opt.on('', '--table-options OPTIONS') {|v| options[:table_options] = v } @@ -100,15 +103,11 @@ begin logger = Ridgepole::Logger.instance logger.set_debug(options[:debug]) - if config - config = File.read(config) if File.exist?(config) - config = YAML.load(config) - client = Ridgepole::Client.new(config, options) - end + client = Ridgepole::Client.new(Ridgepole::Config.load(config, env), options) if config ActiveRecord::Base.logger = logger case mode when :export @@ -177,10 +176,15 @@ end when :diff diff_files = diff_files.map do |file| if File.exist?(file) file_ext = File.extname(file) - %w(.yml .yaml).include?(file_ext) ? YAML.load_file(file) : File.read(file) + + if %w(.yml .yaml).include?(file_ext) + Ridgepole::Config.load(file, env) + else + File.read(file) + end else YAML.load(file) end end