Class: GLI::CommandLineOption
- Inherits:
-
CommandLineToken
- Object
- CommandLineToken
- GLI::CommandLineOption
- Defined in:
- lib/gli/command_line_option.rb
Overview
An option, not a command or argument, on the command line
Instance Attribute Summary collapse
-
#associated_command ⇒ Object
Command to which this option “belongs”, nil if it’s a global option.
-
#default_value ⇒ Object
:nodoc:.
Attributes inherited from CommandLineToken
#aliases, #description, #long_description, #name
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(names, options = {}) ⇒ CommandLineOption
constructor
Creates a new option.
Methods inherited from CommandLineToken
Constructor Details
#initialize(names, options = {}) ⇒ CommandLineOption
Creates a new option
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
:default_value - the default value of this option
18 19 20 21 |
# File 'lib/gli/command_line_option.rb', line 18 def initialize(names, = {}) super(names,[:desc],[:long_desc]) @default_value = [:default_value] end |
Instance Attribute Details
#associated_command ⇒ Object
Command to which this option “belongs”, nil if it’s a global option
9 10 11 |
# File 'lib/gli/command_line_option.rb', line 9 def associated_command @associated_command end |
#default_value ⇒ Object
:nodoc:
7 8 9 |
# File 'lib/gli/command_line_option.rb', line 7 def default_value @default_value end |
Class Method Details
.name_as_string(name, negatable = true) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gli/command_line_option.rb', line 23 def self.name_as_string(name,negatable=true) string = name.to_s if string.length == 1 "-#{string}" elsif negatable "--[no-]#{string}" else "--#{string}" end end |