Sha256: 426e0c0b5e5c57b4112b91bfcb685d5397d63681f87f4be1cedb7b0ead3329c9

Contents?: true

Size: 868 Bytes

Versions: 20

Compression:

Stored size: 868 Bytes

Contents

# frozen_string_literal: true
# A simple boolean.
class Puppet::Settings::BooleanSetting < Puppet::Settings::BaseSetting
  # get the arguments in getopt format
  def getopt_args
    if short
      [["--#{name}", "-#{short}", GetoptLong::NO_ARGUMENT], ["--no-#{name}", GetoptLong::NO_ARGUMENT]]
    else
      [["--#{name}", GetoptLong::NO_ARGUMENT], ["--no-#{name}", GetoptLong::NO_ARGUMENT]]
    end
  end

  def optparse_args
    if short
      ["--[no-]#{name}", "-#{short}", desc, :NONE ]
    else
      ["--[no-]#{name}", desc, :NONE]
    end
  end

  def munge(value)
    case value
    when true, "true"; return true
    when false, "false"; return false
    else
      raise Puppet::Settings::ValidationError, _("Invalid value '%{value}' for boolean parameter: %{name}") % { value: value.inspect, name: @name }
    end
  end

  def type
    :boolean
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/settings/boolean_setting.rb
puppet-8.3.0-x86-mingw32 lib/puppet/settings/boolean_setting.rb
puppet-8.3.0-x64-mingw32 lib/puppet/settings/boolean_setting.rb
puppet-8.3.0-universal-darwin lib/puppet/settings/boolean_setting.rb
puppet-8.3.1 lib/puppet/settings/boolean_setting.rb
puppet-8.3.1-x86-mingw32 lib/puppet/settings/boolean_setting.rb
puppet-8.3.1-x64-mingw32 lib/puppet/settings/boolean_setting.rb
puppet-8.3.1-universal-darwin lib/puppet/settings/boolean_setting.rb
puppet-8.2.0 lib/puppet/settings/boolean_setting.rb
puppet-8.2.0-x86-mingw32 lib/puppet/settings/boolean_setting.rb
puppet-8.2.0-x64-mingw32 lib/puppet/settings/boolean_setting.rb
puppet-8.2.0-universal-darwin lib/puppet/settings/boolean_setting.rb
puppet-8.1.0 lib/puppet/settings/boolean_setting.rb
puppet-8.1.0-x86-mingw32 lib/puppet/settings/boolean_setting.rb
puppet-8.1.0-x64-mingw32 lib/puppet/settings/boolean_setting.rb
puppet-8.1.0-universal-darwin lib/puppet/settings/boolean_setting.rb
puppet-8.0.1 lib/puppet/settings/boolean_setting.rb
puppet-8.0.1-x86-mingw32 lib/puppet/settings/boolean_setting.rb
puppet-8.0.1-x64-mingw32 lib/puppet/settings/boolean_setting.rb
puppet-8.0.1-universal-darwin lib/puppet/settings/boolean_setting.rb