Method: Moonshot::CommandLine#load_commands

Defined in:
lib/moonshot/command_line.rb

#load_commandsObject



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/moonshot/command_line.rb', line 104

def load_commands
  @commands = {}

  # Include all Moonshot::Command and Moonshot::SSHCommand
  # derived classes as subcommands, with the description of their
  # default task.
  self.class.registered_commands.each do |klass|
    next unless klass.instance_methods.include?(:execute)

    command_name = commandify(klass)
    @commands[command_name] = klass
  end

  @commands = @commands.sort_by { |k, _v| k.to_s }.to_h
end