Method: Financo::CLI::Program::Parser#parse

Defined in:
lib/financo/cli/program/parser.rb

#parse(argv) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/financo/cli/program/parser.rb', line 46

def parse(argv)
  options = {
    checking: DEFAULT_CHECKING,
    output: DEFAULT_OUTPUT.sub('<timestamp>', Time.now.to_i.to_s)
  }
  args = @op.parse(argv, into: options)

  unless options[:help] || options[:version]
    raise ParserError, "expected: '<username> <password>'." if
      args.length != 2
  end

  [args, options]
rescue OptionParser::MissingArgument => e
  raise ParserError, e
end