module Singel::Config

allow fetching the config anywhere in the app

Public Class Methods

config() click to toggle source

return the config object or parse the options fresh

   # File lib/singel/config.rb
25 def self.config
26   @config ||= parse_opts
27 end
parse_opts() click to toggle source

parse options passed from the command line

   # File lib/singel/config.rb
30 def self.parse_opts
31   options = { :templates => [], :builders => [], :packer_dir => File.expand_path('./packer') }
32   banner = "Singel - Unified system image creation using Packer\n\n" \
33             "Usage: singel [action] [options]\n\n" \
34             "  Actions:\n" \
35             "    build: Build system images\n" \
36             "    list: List available image templates and builder types (AMI, Virtualbox, etc)\n\n" \
37             "  Options:\n"
38   OptionParser.new do |opts|
39     opts.banner = banner
40     opts.on('-t', '--templates t1.json,t2.json', Array, 'Build only the specified comma separated list of templates') do |t|
41       options[:templates] = t
42     end
43     opts.on('-b', '--builders type1,type2', Array, 'Build only the specified comma separated list of builder types') do |b|
44       options[:builders] = b
45     end
46     opts.on('-p', '--packer_dir PATH', 'Path to the packer dir containing templates and other files') do |p|
47       options[:packer_dir] = File.expand_path(p)
48     end
49     opts.on('-h', '--help', 'Displays Help') do
50       puts opts
51       exit
52     end
53   end.parse!(ARGV)
54 
55   options
56 end