Module: EtcdTools::EtcdERB::Options

Defined in:
lib/etcd-tools/etcd_erb/options.rb

Instance Method Summary collapse

Instance Method Details

#optparseObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/etcd-tools/etcd_erb/options.rb', line 6

def optparse
  @options = Hash.new

  @options[:url] = ENV['ETCDCTL_ENDPOINT']
  @options[:url] ||= "http://127.0.0.1:4001"

  OptionParser.new do |opts|
    opts.banner = "Applies variables from ETCD onto ERB template\n\nUsage: #{$0} [OPTIONS] < template.erb > outfile"
    opts.separator ""
    opts.separator "Connection options:"
    opts.on("-u", "--url URL", "URL endpoint of the ETCD service (ETCDCTL_ENDPOINT envvar also applies) [DEFAULT: http://127.0.0.1:4001]") do |param|
      @options[:url] = param
    end
    opts.separator ""
    opts.separator "Common options:"
    opts.on_tail("-h", "--help", "show usage") do |param|
      puts opts
      exit! 0
    end
  end.parse!
end