Class: Packageiq::CLI

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

Overview

Parse CLI arguments

Class Method Summary collapse

Class Method Details

.read(arguments = ARGV) ⇒ Object



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

def self.read(arguments = ARGV)
  options = {}
  optparse = OptionParser.new do |opts|
    opts.on('-h', '--help', 'Display this message') do
      puts opts
      exit
    end

    opts.on('-V', '--version', 'Display Version') do
      puts Packageiq::VERSION
      exit
    end

    opts.on('-c', '--config FILE', 'PackageIQ config FILE') do |file|
      options[:config_file] = file
    end

    opts.on('-d', '--config_dir DIR',
            'DIR for PackageIQ config files') do |dir|
      options[:config_dir] = dir
    end
  end
  optparse.parse!(arguments)
  options
end