Method: Front::CLI::Configuration#parse

Defined in:
lib/front/cli/configuration.rb

#parse(args, options) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/front/cli/configuration.rb', line 48

def parse(args, options)
  parser = get_parser(args, options)

  begin
    parser.parse!(args)
    if options.action.nil?
      if args.length == 1
        options.action = args[0]
      else
        raise OptionParser::InvalidOption.new(args)
      end
    end
  rescue OptionParser::InvalidOption => err
    options.error = err
    options.action = :show_invalid_option
  rescue OptionParser::MissingArgument => err
    options.error = err
    options.action = :show_missing_args
  rescue OptionParser::ParseError => err
    options.error = err
    options.action = :show_parser_error
  end

  options
end