struct Athena::Console::Loader::Factory

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.cr

Constructors

Instance Method Summary

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

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

[View source]

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.


[View source]
def has?(name : String) : Bool #

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


[View source]
def names : Array(String) #

Returns all of the command names defined within self.


[View source]