Class: Ffsr::OptParse

Inherits:
Object
  • Object
show all
Defined in:
lib/ffsr/OptParse.rb

Overview

:opterrors - counter of errors in parsing and postprocessing

Class Method Summary collapse

Class Method Details

.parse(argv) ⇒ Object



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
# File 'lib/ffsr/OptParse.rb', line 8

def self.parse(argv)
  options = {:opterrors => 0}
  opterrors = 0

  opt_parser = OptionParser.new do |opt|
    opt.banner = 'Usage: ffsr FFSR_batch_files [options]'

    opt.on('--dry-run', 'Does everything as usual except creating output files') do
      options[:dryrun] = true
    end

    opt.on_tail('-V', '--verbose', 'Verbose output') do
      options[:verbose] = true
    end

    opt.on_tail('-v', '--version', 'Show version') do
      puts APPNAME + ' ' + VERSION
      exit NORMAL_EXIT
    end
  end   # opt_parser = OptionParser.new do |opt|
  begin
    opt_parser.parse!
  rescue => e
    puts 'Errors on the command line'
    opterrors += 1
  end

  options[:opterrors] = opterrors
  options
end