class Matrix::Architect::Commands::Base
- Matrix::Architect::Commands::Base
- Reference
- Object
Overview
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
Direct Known Subclasses
- Matrix::Architect::Commands::Bot
- Matrix::Architect::Commands::Room
- Matrix::Architect::Commands::User
- Matrix::Architect::Commands::Version
Defined in:
commands/base.crConstructors
Class Method Summary
-
.run(args, room_id : String, conn : Connection) : Nil
Creates a new instance of the command and runs it.
Constructor Detail
Class Method Detail
def self.run(args, room_id : String, conn : Connection) : Nil
#
Creates a new instance of the command and runs it.