Class: Swiftproj::HelpCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/swiftproj/commands/help_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#command_class, command_name, #get_command, help_message, #initialize, options, #parse_options

Constructor Details

This class inherits a constructor from Swiftproj::Command

Class Method Details

.descriptionObject



3
4
5
# File 'lib/swiftproj/commands/help_command.rb', line 3

def self.description()
  return "Displays this help message"
end

Instance Method Details

#run(options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/swiftproj/commands/help_command.rb', line 7

def run(options)
  message = Swiftproj.constants
    .map { |symbol| symbol.to_s }
    .select { |name| name != "Command" and name.end_with?("Command") }
    .map { |name| Swiftproj.const_get(name) }
    .map { |cls|
      "    " + cls.command_name.ljust(22).green + cls.description
    }
    .join("\n")
  @ui.puts(message)
end