class JunitModel::CLI::Parser

Parse CLI::Options from ARGV

Public Class Methods

parse(argv) click to toggle source
# File lib/junit_model/cli/cli_parser.rb, line 16
def self.parse(argv)
  options = Options.new
  opt_parser = OptionParser.new do |opts|
    opts.banner = 'Usage: example.rb [options]'

    opts.on('-o', '--output OUTPUT', String, 'Output') do |n|
      options.output_path = n
    end

    opts.on('-h', '--help', 'Prints this help') do
      puts opts
      exit
    end
  end

  opt_parser.order(argv) do |file|
    options.files << file unless file.nil?
  end

  opt_parser.parse(argv)
  options
end