Class: Filecop::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/filecop/options.rb

Class Method Summary collapse

Class Method Details

.parse!(args) ⇒ Object



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

def self.parse!(args)
  # The options specified on the command line will be collected here
  options = OpenStruct.new
  options.json = false

  opt_parser = OptionParser.new do |opts|
    opts.banner = 'Usage: filecop [options] [file1, file2, ...]'

    opts.on("-j", "--json", "Output as JSON") do |v|
      options.json = true
    end

    opts.on_tail('--version', 'Show version') do
      puts Filecop::VERSION
      exit
    end
  end

  opt_parser.parse!(args)
  [options, args]
end