Sha256: 3268e80d2da261baeb2de2ee285e1a87ce02b15a181e8c9ab47a1f3a59918c8f
Contents?: true
Size: 1009 Bytes
Versions: 38
Compression:
Stored size: 1009 Bytes
Contents
# frozen_string_literal: true require 'eac_ruby_utils/core_ext' module EacCli class Definition class BaseOption DEFAULT_REQUIRED = false enable_listable lists.add_symbol :option, :optional, :usage, :required attr_reader :short, :long, :description, :options def initialize(short, long, description, options = {}) @short = short @long = long @description = description @options = options.symbolize_keys @options.assert_valid_keys(::EacCli::Definition::BaseOption.lists.option.values) end def identifier long.to_s.variableize.to_sym end def required? return true if options.key?(:required) && options.fetch(:required) return false if options.key?(:optional) && options.fetch(:optional) DEFAULT_REQUIRED end def to_s "#{self.class.name.demodulize}[#{identifier}]" end def show_on_usage? options[:usage] end end end end
Version data entries
38 entries across 38 versions & 3 rubygems