Sha256: 1a31cb4cb95114edc32dd16028af98b95afef260ee259a9c124e53bec2fb5bf5

Contents?: true

Size: 775 Bytes

Versions: 2

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

module Lino
  module Switches
    def with_option(switch, value, separator: nil, quoting: nil)
      with(switches: add_option(switch, value, separator, quoting))
    end

    def with_repeated_option(switch, values, separator: nil, quoting: nil)
      values.each do |value|
        add_option(switch, value, separator, quoting)
      end
      with({})
    end

    def with_flag(flag)
      with(switches: @switches.add({ components: [flag] }))
    end

    private

    def add_option(switch, value, separator, quoting)
      return @switches if missing?(value)

      @switches = @switches.add(
        {
          components: [switch, value],
          separator: separator,
          quoting: quoting
        }
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lino-1.10.0.pre.2 lib/lino/switches.rb
lino-1.10.0.pre.1 lib/lino/switches.rb