class Smartdict::Commands::HelpCommand

Public Instance Methods

execute() click to toggle source
# File lib/smartdict/commands/help_command.rb, line 23
def execute
  if cmd_name = @arguments[:command]
    if cmd_class = CommandManager.find(cmd_name)
      puts cmd_class.help_message
    else
      abort "Uknown command: #{cmd_name}"
    end
  else
    puts help_message
  end
end
help_commands_message() click to toggle source
# File lib/smartdict/commands/help_command.rb, line 42
def help_commands_message
  width = CommandManager.all.keys.map(&:size).max
  result = " " * INDENT_SIZE + "Commands:\n"
  CommandManager.all.each do |command_name, command_class|
    result << " " * 2 * INDENT_SIZE + "#{command_name.ljust(width)}"
    result << "    #{command_class.summary}\n"
  end
  result
end
help_message() click to toggle source
# File lib/smartdict/commands/help_command.rb, line 35
def help_message
  message = "#{description}\n\n"
  message << "#{self.class.help_syntax_message}\n"
  message << help_commands_message
end