Class: Kongfigure::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kongfigure/cli.rb', line 7

def initialize
  @options       = {
    debug: false
  }
  @option_parser = OptionParser.new do |parser|
    parser.on("-f", "--file FILE", "Path to the Kongfigure configuration file.") do |file|
      @options[:file] = file
    end
    parser.on("-u", "--url URL", "Url to the kong admin API.") do |url|
      @options[:url] = url
    end
    parser.on("-d", "--debug", "Debug mode.") do
      @options[:debug] = true
    end
    parser.on("-v", "--version", "Display version and exit.") do
      puts "Kongfigure version: #{Kongfigure::VERSION}"
      exit 0
    end
  end
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/kongfigure/cli.rb', line 5

def options
  @options
end

Instance Method Details

#parse!(args) ⇒ Object



28
29
30
31
# File 'lib/kongfigure/cli.rb', line 28

def parse!(args)
  @option_parser.parse!(args)
  @options
end