Skip to content

struct Athena::Console::Loader::Factory
inherits Struct #

A default implementation of ACON::Loader::Interface that accepts a Hash(String, Proc(ACON::Command)).

A factory could then be set on the ACON::Application:

application = MyCustomApplication.new "My CLI"

application.command_loader = Athena::Console::Loader::Factory.new({
  "command1"        => Proc(ACON::Command).new { Command1.new },
  "app:create-user" => Proc(ACON::Command).new { CreateUserCommand.new },
})

application.run

Included modules

Athena::Console::Loader::Interface

Constructors#

.new(factories : Hash(String, Proc(ACON::Command)))#

Methods#

#get(name : String) : ACON::Command#

Returns an ACON::Command with the provided name. Raises ACON::Exception::CommandNotFound if it is not defined.

#has?(name : String) : Bool#

Returns true if self has a command with the provided name, otherwise false.

#names : Array(String)#

Returns all of the command names defined within self.