Sha256: 44f73c38460e1b4f76ea18b6d59ae43b0b38ac8aad653886938c3ccabfc57346

Contents?: true

Size: 882 Bytes

Versions: 11

Compression:

Stored size: 882 Bytes

Contents

require 'gli/command_line_option.rb'

module GLI
  # Defines a command line switch
  class Switch < CommandLineOption #:nodoc:

    attr_accessor :default_value
    attr_reader :negatable

    # Creates a new switch
    #
    # names - Array of symbols or strings representing the names of this switch
    # options - hash of options:
    #           :desc - the short description
    #           :long_desc - the long description
    #           :negatable - true or false if this switch is negatable; defaults to true
    #           :default_value - ignored, switches default to false
    def initialize(names,options = {})
      super(names,options)
      @default_value = false
      @negatable = options[:negatable].nil? ? true : options[:negatable]
    end

    def arguments_for_option_parser
      all_forms_a
    end

    def negatable?
      @negatable
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gli-2.4.1 lib/gli/switch.rb
gli-2.4.0 lib/gli/switch.rb
gli-2.3.0 lib/gli/switch.rb
gli-2.3.0.rc1 lib/gli/switch.rb
gli-2.2.1 lib/gli/switch.rb
gli-2.2.0 lib/gli/switch.rb
gli-2.1.0 lib/gli/switch.rb
gli-2.0.0 lib/gli/switch.rb
gli-2.0.0.rc8 lib/gli/switch.rb
gli-2.0.0.rc7 lib/gli/switch.rb
gli-2.0.0.rc6 lib/gli/switch.rb