Sha256: 5f76c1e5a9cc7ad193003049a0b0fbc8a606964509e46fdea9e33364889251c4
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
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 - default value if the switch is omitted def initialize(names,options = {}) super(names,options) @default_value = false if options[:default_value].nil? @negatable = options[:negatable].nil? ? true : options[:negatable] if @default_value != false && @negatable == false raise "A switch with default #{@default_value} that isn't negetable is useless" end end def arguments_for_option_parser all_forms_a end def negatable? @negatable end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
gli-2.5.4 | lib/gli/switch.rb |
gli-2.5.3 | lib/gli/switch.rb |
gli-2.5.2 | lib/gli/switch.rb |
gli-2.5.1 | lib/gli/switch.rb |
gli-2.5.0 | lib/gli/switch.rb |