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

Version Path
avm-tools-0.91.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
avm-tools-0.90.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
avm-tools-0.89.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
avm-tools-0.88.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
eac_cli-0.12.6 lib/eac_cli/definition/base_option.rb
avm-tools-0.87.1 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
ehbrs-tools-0.19.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
ehbrs-tools-0.18.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
eac_cli-0.12.5 lib/eac_cli/definition/base_option.rb
avm-tools-0.87.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
ehbrs-tools-0.17.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
avm-tools-0.86.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
avm-tools-0.85.1 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
avm-tools-0.85.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
ehbrs-tools-0.16.5 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
avm-tools-0.84.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
avm-tools-0.83.0 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
eac_cli-0.12.4 lib/eac_cli/definition/base_option.rb
ehbrs-tools-0.16.4 vendor/eac_cli/lib/eac_cli/definition/base_option.rb
avm-tools-0.82.1 vendor/eac_cli/lib/eac_cli/definition/base_option.rb