Class: Relish::Command::Dsl::HelpText
- Inherits:
-
Object
- Object
- Relish::Command::Dsl::HelpText
- Defined in:
- lib/relish/commands/dsl/help_text.rb
Class Attribute Summary collapse
-
.current_command ⇒ Object
Returns the value of attribute current_command.
-
.next_description ⇒ Object
Returns the value of attribute next_description.
-
.next_usage ⇒ Object
Returns the value of attribute next_usage.
Class Method Summary collapse
- .add(name, command) ⇒ Object
- .clear_commands ⇒ Object
- .commands ⇒ Object
- .get_next_description ⇒ Object
- .get_next_usage ⇒ Object
- .max_usage_length ⇒ Object
- .reset_accessors ⇒ Object
Class Attribute Details
.current_command ⇒ Object
Returns the value of attribute current_command.
7 8 9 |
# File 'lib/relish/commands/dsl/help_text.rb', line 7 def current_command @current_command end |
.next_description ⇒ Object
Returns the value of attribute next_description.
7 8 9 |
# File 'lib/relish/commands/dsl/help_text.rb', line 7 def next_description @next_description end |
.next_usage ⇒ Object
Returns the value of attribute next_usage.
7 8 9 |
# File 'lib/relish/commands/dsl/help_text.rb', line 7 def next_usage @next_usage end |
Class Method Details
.add(name, command) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/relish/commands/dsl/help_text.rb', line 9 def add(name, command) self.current_command = name commands[command] = [] unless commands.key?(command) commands[command].push(get_next_usage => get_next_description) reset_accessors end |
.clear_commands ⇒ Object
34 35 36 |
# File 'lib/relish/commands/dsl/help_text.rb', line 34 def clear_commands @commands = {} end |
.commands ⇒ Object
26 27 28 |
# File 'lib/relish/commands/dsl/help_text.rb', line 26 def commands @commands ||= {} end |
.get_next_description ⇒ Object
20 21 22 23 24 |
# File 'lib/relish/commands/dsl/help_text.rb', line 20 def get_next_description next_description || raise( "please set a description for #{current_command.inspect}" ) end |
.get_next_usage ⇒ Object
16 17 18 |
# File 'lib/relish/commands/dsl/help_text.rb', line 16 def get_next_usage next_usage or current_command.to_s end |
.max_usage_length ⇒ Object
38 39 40 41 42 |
# File 'lib/relish/commands/dsl/help_text.rb', line 38 def max_usage_length commands.values.map {|v| v.map {|v| v.keys.to_s.length }.max }.max end |
.reset_accessors ⇒ Object
30 31 32 |
# File 'lib/relish/commands/dsl/help_text.rb', line 30 def reset_accessors self.current_command = self.next_usage = self.next_description = nil end |