class Spring::Client::Help
Attributes
application_commands[R]
spring_commands[R]
Public Class Methods
call(args)
click to toggle source
Calls superclass method
Spring::Client::Command.call
# File lib/spring/client/help.rb, line 12 def self.call(args) require "spring/commands" super end
description()
click to toggle source
# File lib/spring/client/help.rb, line 8 def self.description "Print available commands." end
new(args, spring_commands = nil, application_commands = nil)
click to toggle source
Calls superclass method
Spring::Client::Command.new
# 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
Public Instance Methods
call()
click to toggle source
# File lib/spring/client/help.rb, line 28 def call puts formatted_help end
command_help(subject, commands)
click to toggle source
# 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()
click to toggle source
# 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
Private Instance Methods
all_commands()
click to toggle source
# File lib/spring/client/help.rb, line 47 def all_commands spring_commands.merge application_commands end
display(name, command)
click to toggle source
# File lib/spring/client/help.rb, line 51 def display(name, command) if command.description " #{name.ljust(max_name_width)} #{command.description}" end end
max_name_width()
click to toggle source
# File lib/spring/client/help.rb, line 57 def max_name_width @max_name_width ||= all_commands.keys.map(&:length).max end