Class: StackedConfig::Layers::CommandLineLayer
- Inherits:
-
SuperStack::Layer
- Object
- SuperStack::Layer
- StackedConfig::Layers::CommandLineLayer
- Defined in:
- lib/stacked_config/layers/command_line_layer.rb
Instance Attribute Summary collapse
-
#slop_definition ⇒ Object
readonly
Returns the value of attribute slop_definition.
Instance Method Summary collapse
-
#add_command_line_section(title) {|slop_definition| ... } ⇒ Object
Yields a slop definition to modify the command line parameters.
-
#help ⇒ String
The formatted command line help.
-
#initialize ⇒ CommandLineLayer
constructor
A new instance of CommandLineLayer.
- #load(*args) ⇒ Object
- #possible_options ⇒ Object
- #reload ⇒ Object
Constructor Details
#initialize ⇒ CommandLineLayer
Returns a new instance of CommandLineLayer.
8 9 10 11 |
# File 'lib/stacked_config/layers/command_line_layer.rb', line 8 def initialize @slop_definition = Slop.new end |
Instance Attribute Details
#slop_definition ⇒ Object (readonly)
Returns the value of attribute slop_definition.
6 7 8 |
# File 'lib/stacked_config/layers/command_line_layer.rb', line 6 def slop_definition @slop_definition end |
Instance Method Details
#add_command_line_section(title) {|slop_definition| ... } ⇒ Object
Yields a slop definition to modify the command line parameters
28 29 30 31 32 33 |
# File 'lib/stacked_config/layers/command_line_layer.rb', line 28 def add_command_line_section(title) raise 'Incorrect usage' unless block_given? slop_definition.separator build_separator(title) yield slop_definition reload end |
#help ⇒ String
Returns The formatted command line help.
36 37 38 |
# File 'lib/stacked_config/layers/command_line_layer.rb', line 36 def help slop_definition.to_s end |
#load(*args) ⇒ Object
13 14 15 16 17 |
# File 'lib/stacked_config/layers/command_line_layer.rb', line 13 def load(*args) slop_definition.parse slop_definition. = replace slop_definition.to_hash.delete_if {|k,v| v.nil?} end |
#possible_options ⇒ Object
19 20 21 |
# File 'lib/stacked_config/layers/command_line_layer.rb', line 19 def slop_definition.to_hash.keys.sort end |
#reload ⇒ Object
23 24 25 |
# File 'lib/stacked_config/layers/command_line_layer.rb', line 23 def reload load end |