5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/erb-hiera/cli.rb', line 5
def self.parse
option_parser = Trollop::Parser.new do
opt :config, "specify config file", :type => :string
opt :hiera_config, "specify hiera config file", :type => :string
opt :verbose, "print compiled templates"
opt :debug, "print backtrace on error"
opt :dry_run, "don't write out files"
end
options = Trollop.with_standard_exception_handling(option_parser) do
raise Trollop::HelpNeeded if ARGV.empty?
option_parser.parse ARGV
end
raise ArgumentError, "config file not specified" unless options[:config_given]
raise ArgumentError, "config file not readable" unless File.readable?(options[:config])
raise ArgumentError, "hiera config file not specified" unless options[:hiera_config_given]
raise ArgumentError, "hiera config file not readable" unless File.readable?(options[:hiera_config])
options
rescue => error
puts error
puts error.backtrace if options[:debug]
exit 1
end
|