Sha256: 522f3fd828df94f8b1e84adcb1fbd46598df19fdcb81147158bafe2c3be4b3b8

Contents?: true

Size: 672 Bytes

Versions: 31

Compression:

Stored size: 672 Bytes

Contents

# Class to delay the case options configuration (declaration vs configuration)
class Eco::API::UseCases::Cli
  class Option
    attr_accessor :name, :desc, :callback

    def initialize(name, desc, &block)
      @name, @desc, @callback = name, desc, block
    end

    def dup(name: self.name, desc: self.desc, &block)
      self.class.new(name, desc, &(block || callback))
    end

    def link_case(cli_config_case)
      raise ArgumentError, "cli_config_case must have an 'add_option' method. Given: #{cli_config_case.class}" unless cli_config_case.respond_to?(:add_option)

      cli_config_case.add_option(name, desc, &callback)
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.20 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.19 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.18 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.17 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.16 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.15 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.14 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.13 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.12 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.11 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.10 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.9 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.8 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.7 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.6 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.5 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.4 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.3 lib/eco/api/usecases/cli/option.rb
eco-helpers-3.0.2 lib/eco/api/usecases/cli/option.rb