Yeesh.Registry
(Yeesh v0.8.1)
View Source
ETS-backed command registry.
Stores command modules keyed by their name. Only the help built-in
is registered on application start. Additional built-ins are registered
when the terminal component mounts according to the :builtins option
(defaults to :help). Consumer commands are also registered on mount.
See resolve_builtins/1 for the accepted values of :builtins.
Summary
Functions
Returns the list of built-in command modules.
Returns a specification to start this module under a supervisor.
Returns command names matching the given prefix.
Returns all registered command names.
Returns all registered {name, module} pairs.
Looks up a command module by name.
Finds the longest registered command that matches a prefix of the given
tokens. Returns {:ok, command_name, remaining_args} if any registered
command matches, otherwise :error.
Normalizes a command name: trims outer whitespace and collapses any run of internal whitespace into a single space.
Registers a command module.
Registers multiple command modules.
Clears the registry and re-registers only the default builtins (:help).
Resolves a builtins option into a list of command modules.
Starts the registry.
Types
@type builtins_opt() :: :all | :none | :help | [module()]
Functions
@spec builtin_commands() :: [module()]
Returns the list of built-in command modules.
Returns a specification to start this module under a supervisor.
See Supervisor.
Returns command names matching the given prefix.
@spec list() :: [String.t()]
Returns all registered command names.
Returns all registered {name, module} pairs.
Looks up a command module by name.
Finds the longest registered command that matches a prefix of the given
tokens. Returns {:ok, command_name, remaining_args} if any registered
command matches, otherwise :error.
Used by the executor to resolve multi-word commands after tokenization.
Normalizes a command name: trims outer whitespace and collapses any run of internal whitespace into a single space.
@spec register(module()) :: :ok
Registers a command module.
@spec register_all([module()]) :: :ok
Registers multiple command modules.
@spec reset() :: :ok
Clears the registry and re-registers only the default builtins (:help).
@spec resolve_builtins(builtins_opt()) :: [module()]
Resolves a builtins option into a list of command modules.
Accepted values:
:all-- all built-in commands:none-- no built-in commands:help-- only thehelpcommand (default)- a list of command modules -- those exact modules
@spec start_link(keyword()) :: GenServer.on_start()
Starts the registry.