Class: Spring::Client::Help

Inherits:
Command
  • Object
show all
Defined in:
lib/spring/client/help.rb

Instance Attribute Summary collapse

Attributes inherited from Command

#args, #env

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

call

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_commandsObject (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_commandsObject (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

.descriptionObject



8
9
10
# File 'lib/spring/client/help.rb', line 8

def self.description
  "Print available commands."
end

Instance Method Details

#application_command_helpObject



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

#callObject



19
20
21
# File 'lib/spring/client/help.rb', line 19

def call
  puts formatted_help
end

#formatted_helpObject



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_helpObject



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