Method: Stem::CLI#parse_options

Defined in:
lib/stem/cli.rb

#parse_options(args) ⇒ Object

Return a structure describing the options.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/stem/cli.rb', line 12

def parse_options(args)
  opts = OptionParser.new do |opts|
    opts.banner = "Usage: stem COMMAND ..."

    opts.separator " "

    opts.separator "Examples:"
    opts.separator "  $ stem launch prototype.config prototype-userdata.sh"
    opts.separator "  $ stem launch examples/lxc-server/lxc-server.json examples/lxc-server/"
    opts.separator "  $ stem list"
    opts.separator "  $ stem create ami-name instance-id ami_tag1,ami_tag2"
    opts.separator "  $ stem destroy ami-name"

    opts.separator " "
    opts.separator "Options:"

    opts.on("-v", "--version", "Print the version") do |v|
      puts "Stem v#{Stem::Version}"
      exit
    end

    opts.on_tail("-h", "--help", "Show this message") do
      puts opts
      exit
    end
  end

  opts.separator ""

  opts.parse!(args)
end