Class: OmniCli::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/omnicli/parser.rb

Overview

Parser for Omni CLI arguments from environment variables

Instance Method Summary collapse

Instance Method Details

#parse!Hash{Symbol => Object}

Parse arguments from environment variables into a Hash with symbol keys

Examples:

parser = OmniCli::Parser.new
args = parser.parse!
puts args[:verbose] if args[:verbose]

Returns:

  • (Hash{Symbol => Object})

    parsed arguments with proper types

Raises:



19
20
21
22
23
24
25
26
# File 'lib/omnicli/parser.rb', line 19

def parse!
  list = arg_list
  return {} if list.empty?

  list.each_with_object({}) do |name, args|
    args[name.downcase.to_sym] = parse_argument(name)
  end
end