Sha256: fab4779954514ad7bfcadfa8795d6147af5ae0060930029b650a2bb99b6877c0

Contents?: true

Size: 573 Bytes

Versions: 8

Compression:

Stored size: 573 Bytes

Contents

module EverydayCliUtils
  class Option
    def self.add_option(options, opts, names, opt_name, settings = {})
      opts.on(*names) {
        options[opt_name] = !settings[:toggle] || !options[opt_name]
        yield if block_given?
      }
    end

    def self.add_option_with_param(options, opts, names, opt_name, settings = {})
      opts.on(*names, settings[:type] || String) { |param|
        if settings[:append]
          options[opt_name] << param
        else
          options[opt_name] = param
        end
        yield if block_given?
      }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
everyday-cli-utils-0.5.1 lib/everyday-cli-utils/option.rb
everyday-cli-utils-0.5.0 lib/everyday-cli-utils/option.rb
everyday-cli-utils-0.4.0 lib/everyday-cli-utils/option.rb
everyday-cli-utils-0.3.0 lib/everyday-cli-utils/option.rb
everyday-cli-utils-0.2.1 lib/everyday-cli-utils/option.rb
everyday-cli-utils-0.2.0 lib/everyday-cli-utils/option.rb
everyday-cli-utils-0.1.0 lib/everyday-cli-utils/option.rb
everyday-cli-utils-0.0.2 lib/everyday-cli-utils/option.rb