class

Matrix::Architect::Commands::Base

Inherits Reference / Object

Base class for all commands.

The command reiceve an OptionParser an a Job on its run method. It should use the parser to define any subcommands or options and the job to register the code that will actually execute after the whole parsing process.

Example:

class HelloWorldCommand < Base
  @flag : String? = nil

  def parse(parser, job)
    parser.on("subcommand", "a subcommand example") do
      parser.on("-f FLAG", "--flag=FLAG", "a flag example") do |flag|
        @flag = flag
      end
      job.exec { subcommand }
    end
  end

  def subcommand
    send_message "Hello world with a subcommand"

    if !@flag.nil?
      send_message "You sent the flag #{@flag}"
    end
  end
end

Constructors

new(room_id : String, conn : Connection)
Source

Class methods

run(args, room_id : String, conn : Connection) : Nil

Creates a new instance of the command and runs it.

Source

Nested types