Class: Spring::Client::Help
- Defined in:
- lib/spring/client/help.rb
Instance Attribute Summary collapse
-
#application_commands ⇒ Object
readonly
Returns the value of attribute application_commands.
-
#spring_commands ⇒ Object
readonly
Returns the value of attribute spring_commands.
Attributes inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
- #application_command_help ⇒ Object
- #call ⇒ Object
- #formatted_help ⇒ Object
-
#initialize(args, spring_commands = nil, application_commands = nil) ⇒ Help
constructor
A new instance of Help.
- #spring_command_help ⇒ Object
Methods inherited from Command
Constructor Details
#initialize(args, spring_commands = nil, application_commands = nil) ⇒ Help
Returns a new instance of Help.
12 13 14 15 16 17 |
# File 'lib/spring/client/help.rb', line 12 def initialize(args, spring_commands = nil, application_commands = nil) super args @spring_commands = spring_commands || Spring::Client::COMMANDS @application_commands = application_commands || Spring.commands end |
Instance Attribute Details
#application_commands ⇒ Object (readonly)
Returns the value of attribute application_commands.
6 7 8 |
# File 'lib/spring/client/help.rb', line 6 def application_commands @application_commands end |
#spring_commands ⇒ Object (readonly)
Returns the value of attribute spring_commands.
6 7 8 |
# File 'lib/spring/client/help.rb', line 6 def spring_commands @spring_commands end |
Class Method Details
.description ⇒ Object
8 9 10 |
# File 'lib/spring/client/help.rb', line 8 def self.description "Print available commands." end |
Instance Method Details
#application_command_help ⇒ Object
35 36 37 38 |
# File 'lib/spring/client/help.rb', line 35 def application_command_help ["Commands for your application:\n", *registered_commands.map { |c,n| display_value(c,n) }] end |
#call ⇒ Object
19 20 21 |
# File 'lib/spring/client/help.rb', line 19 def call puts formatted_help end |
#formatted_help ⇒ Object
23 24 25 26 27 28 |
# File 'lib/spring/client/help.rb', line 23 def formatted_help ["Usage: spring COMMAND [ARGS]\n", *spring_command_help, '', *application_command_help].join("\n") end |
#spring_command_help ⇒ Object
30 31 32 33 |
# File 'lib/spring/client/help.rb', line 30 def spring_command_help ["Commands for spring itself:\n", *client_commands.map { |c,n| display_value(c,n) }] end |