bin/rivet in rivet-1.4.0 vs bin/rivet in rivet-2.0.0

- old
+ new

@@ -1,48 +1,52 @@ #!/usr/bin/env ruby +# encoding: UTF-8 -$:.unshift(File.join(File.dirname(__FILE__), "..", "lib")) +$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'rivet' -require 'rivet/client' DEBUG = Logger::DEBUG WARN = Logger::WARN FATAL = Logger::FATAL INFO = Logger::INFO # Default option values -options = { - :log_level => INFO, - :profile => 'default', - :definitions_directory => './autoscale' -} +options = OpenStruct.new +options.log_level = INFO +options.profile = 'default' +options.config_path = File.join('.', 'autoscale') OptionParser.new do |o| o.on('-g', '--group [GROUP_NAME]', String, 'Autoscaling group name') do |g| - options[:group] = g + options.group = g end - o.on('-l', '--log-level [LEVEL]', String, "specify the log level (default is INFO)") do |l| - options[:log_level] = Kernel.const_get l.upcase + o.on('-l', '--log-level [LEVEL]', String, 'specify the log level (default is INFO)') do |l| + options.log_level = Kernel.const_get l.upcase end - o.on('-p', '--profile [PROFILE_NAME]', "Selects the AWS profile to use (default is 'default')") do |p| - options[:profile] = p + o.on('-p', '--profile [PROFILE_NAME]', 'Selects the AWS profile to use (default is "default")') do |p| + options.profile = p end - o.on('-s', '--sync', "Sync the changes remotely to AWS") do |s| - options[:sync] = s + o.on('-s', '--sync', 'Sync the changes remotely to AWS') do |s| + options.sync = s end - o.on('-d', '--definitions-directory [PATH]', "The autoscale definitions directory to use (default is ./autoscale)") do |d| - options[:definitions_directory] = d + o.on('-c', '--config-path [PATH]', 'The configuration path to use (default is ./autoscale)') do |c| + options.config_path = c end - o.on('-h') { puts o; exit } - o.parse! -end + o.on('-h') { Rivet::Log.info o; exit } -raise "--group [GROUP_NAME] argument is required!" if options[:group].nil? + begin + o.parse! + rescue OptionParser::InvalidOption, OptionParser::MissingArgument + Rivet::Log.fatal $!.to_s + Rivet::Log.fatal o + exit 255 + end +end Rivet::Client.new.run(options)