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
- #call ⇒ Object
- #command_help(subject, commands) ⇒ Object
- #formatted_help ⇒ Object
-
#initialize(args, spring_commands = nil, application_commands = nil) ⇒ Help
constructor
A new instance of Help.
Constructor Details
#initialize(args, spring_commands = nil, application_commands = nil) ⇒ Help
Returns a new instance of Help.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spring/client/help.rb', line 17 def initialize(args, spring_commands = nil, application_commands = nil) super args @spring_commands = spring_commands || Spring::Client::COMMANDS.dup @application_commands = application_commands || Spring.commands.dup @spring_commands.delete_if { |k, v| k.start_with?("-") } @application_commands["rails"] = @spring_commands.delete("rails") 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
.call(args) ⇒ Object
12 13 14 15 |
# File 'lib/spring/client/help.rb', line 12 def self.call(args) require "spring/commands" super end |
.description ⇒ Object
8 9 10 |
# File 'lib/spring/client/help.rb', line 8 def self.description "Print available commands." end |
Instance Method Details
#call ⇒ Object
28 29 30 |
# File 'lib/spring/client/help.rb', line 28 def call puts formatted_help end |
#command_help(subject, commands) ⇒ Object
40 41 42 43 |
# File 'lib/spring/client/help.rb', line 40 def command_help(subject, commands) ["Commands for #{subject}:\n", *commands.sort_by(&:first).map { |name, command| display(name, command) }.compact] end |
#formatted_help ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/spring/client/help.rb', line 32 def formatted_help ["Version: #{env.version}\n", "Usage: spring COMMAND [ARGS]\n", *command_help("Spring itself", spring_commands), '', *command_help("your application", application_commands)].join("\n") end |