struct Athena::Console::Loader::Factory
- Athena::Console::Loader::Factory
- Struct
- Value
- Object
Overview
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
Defined in:
loader/factory.crConstructors
Instance Method Summary
-
#get(name : String) : ACON::Command
Returns an
ACON::Command
with the provided name. -
#has?(name : String) : Bool
Returns
true
ifself
has a command with the provided name, otherwisefalse
. -
#names : Array(String)
Returns all of the command names defined within
self
.
Instance methods inherited from module Athena::Console::Loader::Interface
get(name : String) : ACON::Command
get,
has?(name : String) : Bool
has?,
names : Array(String)
names
Constructor Detail
Instance Method Detail
def get(name : String) : ACON::Command
#
Returns an ACON::Command
with the provided name.
Raises ACON::Exceptions::CommandNotFound
if it is not defined.
def has?(name : String) : Bool
#
Returns true
if self
has a command with the provided name, otherwise false
.