Class: ElasticDot::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticdot/cli.rb

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



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
42
43
44
# File 'lib/elasticdot/cli.rb', line 10

def self.parse(args)
  options = {}

  opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: example.rb [options]"

    opts.on("-a", "--app APP", "Specify the app involved") do |v|
      options[:app] = v
    end

    opts.on("-d", "--database DATABASE", "Specify the database involved") do |v|
      options[:db] = v
    end

    opts.on("-f", "--follow", "Continue running and print new events (off)") do |v|
      options[:follow] = v
    end

    opts.on("-p", "--plan PLAN", "Specify pricing plan") do |v|
      options[:plan] = v
    end

    opts.on("-c", "--extra-conf CONF", "Specify extra config file") do |v|
      options[:conf] = v
    end

    opts.on("-h", "--help", "Show this help") do |v|
      options[:help] = true
    end
  end

  opt_parser.parse! args

  [ARGV, options]
end

.run(args) ⇒ Object



46
47
48
49
# File 'lib/elasticdot/cli.rb', line 46

def self.run(args)
  cmd, opts = parse ARGV
  ElasticDot::Command.run cmd, opts
end