Sha256: 7b6584e75bc60ca737ce4c119f3d7b32a7a87d2224e184f35c200dc37a871cda
Contents?: true
Size: 880 Bytes
Versions: 138
Compression:
Stored size: 880 Bytes
Contents
# frozen_string_literal: true require 'eac_ruby_utils/core_ext' module EacCli class Parser require_sub __FILE__ enable_simple_cache common_constructor :definition, :argv private def parsed_uncached raise 'Definition has no alternatives' if alternatives.empty? raise first_error unless alternatives.select(&:success?).any? alternatives_parsed(true).merge(alternatives_parsed(false)) end def alternatives_parsed(error) alternatives.select { |a| error == a.error? }.map(&:parsed).reverse .inject(::EacRubyUtils::Struct.new) { |a, e| a.merge(e) } end def alternatives_uncached definition.alternatives .map { |alternative| ::EacCli::Parser::Alternative.new(alternative, argv) } end def first_error_uncached alternatives.lazy.select(&:error?).map(&:error).first end end end
Version data entries
138 entries across 138 versions & 3 rubygems