25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/jetty_rails/config/command_line_reader.rb', line 25
def read(default_adapter = :rails)
config = default_config[default_adapter]
opts = GetoptLong.new(
[ '--version', '-v', GetoptLong::NO_ARGUMENT ],
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--context-path', '-u', GetoptLong::REQUIRED_ARGUMENT ],
[ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
[ '--environment', '-e', GetoptLong::REQUIRED_ARGUMENT ],
[ '--lib', '--jars', GetoptLong::REQUIRED_ARGUMENT ],
[ '--classes', GetoptLong::REQUIRED_ARGUMENT ],
[ '--config', '-c', GetoptLong::OPTIONAL_ARGUMENT ]
)
opts.each do |opt, arg|
case opt
when '--version'
require 'jetty_rails/version'
puts "JettyRails version #{JettyRails::VERSION::STRING} - http://jetty-rails.rubyforge.org"
exit(0)
when '--help'
RDoc::usage
when '--context-path'
config[:context_path] = arg
when '--port'
config[:port] = arg.to_i
when '--environment'
config[:environment] = arg
when '--classes'
config[:classes_dir] = arg
when '--lib'
config[:lib_dir] = arg
when '--config'
config[:config_file] = arg if !arg.nil? && arg != ""
end
end
config[:base] = ARGV.shift unless ARGV.empty?
if File.exists?(config[:config_file])
config_file = YAML.load_file(config[:config_file])
config.merge!(config_file[config[:environment]] || config_file) puts "Loaded #{config[:config_file]}"
end
config
end
|