Sha256: 2b8d62d67a26f91fcfdfed3b810306a993895a9219c0f074b53d01c4027c3ed0

Contents?: true

Size: 670 Bytes

Versions: 14

Compression:

Stored size: 670 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

14 entries across 14 versions & 1 rubygems

Version Path
eco-helpers-2.7.16 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.7.15 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.7.14 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.7.13 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.7.12 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.7.4 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.7.2 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.7.1 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.7.0 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.6.4 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.6.3 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.6.2 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.6.1 lib/eco/api/usecases/cli/option.rb
eco-helpers-2.6.0 lib/eco/api/usecases/cli/option.rb