Module: WiotAgentHd::CLI

Defined in:
lib/wiot-agent-hd/cli.rb

Class Method Summary collapse

Class Method Details

.parse_options(args = ARGV) ⇒ Object



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
34
35
36
37
38
39
40
41
# File 'lib/wiot-agent-hd/cli.rb', line 7

def self.parse_options(args=ARGV)
  options = {api_key: nil, space: nil, project: nil}

  parser = OptionParser.new do|opts|
    opts.banner = "Usage: wiot-agent-hd [options]"

    # Mandatory argument.

    opts.on('-a', '--api-key api_key', 'The API Key') do |api_key|
      options[:api_key] = api_key;
    end

    opts.on('-s', '--space space', 'The Space') do |space|
      options[:space] = space;
    end

    opts.on('-p', '--project project', 'The Project') do |project|
      options[:project] = project;
    end

    opts.on_tail('-h', '--help', 'Displays Help') do
      puts opts
      exit
    end

    # Another typical switch to print the version.
    opts.on_tail('-v', '--version', 'Show version') do
      puts WiotAgentHd::VERSION
      exit
    end
  end

  parser.parse!(args)
  options
end

.start(opts) ⇒ Object



43
44
45
# File 'lib/wiot-agent-hd/cli.rb', line 43

def self.start(opts)
  puts opts
end