lib/trinidad/command_line_parser.rb in trinidad-1.0.5 vs lib/trinidad/command_line_parser.rb in trinidad-1.1.0

- old
+ new

@@ -1,8 +1,7 @@ module Trinidad require 'optparse' - require 'yaml' class CommandLineParser attr_reader :default_options def self.parse(argv) @@ -15,11 +14,12 @@ :environment => 'development', :context_path => '', :libs_dir => 'lib', :classes_dir => 'classes', :ssl_port => 8443, - :ajp_port => 8009 + :ajp_port => 8009, + :config => 'config/trinidad.yml' } end def parse!(argv) begin @@ -28,14 +28,17 @@ p e, options_parser exit(1) end if default_options.has_key?(:config) + require 'yaml' default_options[:config] = File.expand_path(default_options[:config], default_options[:web_app_dir] || Dir.pwd) - config_options = YAML.load_file(default_options[:config]) - default_options.deep_merge!(config_options.symbolize!) + if File.exist?(default_options[:config]) + config_options = YAML.load_file(default_options[:config]) + default_options.deep_merge!(config_options.symbolize!) + end end default_options end @@ -86,18 +89,10 @@ default_options[:ajp] = {:port => ajp_port} end opts.on('-f', '--config [CONFIG_FILE]', 'Configuration file', "default: #{default_options[:config]}") do |file| - default_options[:config] = 'config/trinidad.yml' - - if file - default_options[:config] = file - elsif File.exist?('config/tomcat.yml') && !File.exist?(default_options[:config]) - puts "[WARNING] Default configuration file name has been moved to trinidad.yml, tomcat.yml will not be supported in future versions." - puts "\tYou still can use tomcat.yml passing it as the file name to this option: -f config/tomcat.yml" - default_options[:config] = 'config/tomcat.yml' - end + default_options[:config] = file unless file.nil? end opts.on('-r', '--rackup [RACKUP_FILE]', 'Rackup configuration file', 'default: config.ru') do |v| default_options[:rackup] = v || 'config.ru'