yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::cli::CommandRegistry Class Reference

Single source of truth for all z3ed commands. More...

#include <command_registry.h>

Classes

struct  CommandMetadata
 

Public Member Functions

void Register (std::unique_ptr< resources::CommandHandler > handler, const CommandMetadata &metadata)
 Register a command handler.
 
resources::CommandHandlerGet (const std::string &name) const
 Get a command handler by name or alias.
 
const CommandMetadataGetMetadata (const std::string &name) const
 Get command metadata.
 
std::vector< std::string > GetCommandsInCategory (const std::string &category) const
 Get all commands in a category.
 
std::vector< std::string > GetCategories () const
 Get all categories.
 
std::vector< std::string > GetAgentCommands () const
 Get all commands available to AI agents.
 
std::string ExportFunctionSchemas () const
 Export function schemas for AI tool calling (JSON)
 
std::string GenerateHelp (const std::string &name) const
 Generate help text for a command.
 
std::string GenerateCategoryHelp (const std::string &category) const
 Generate category help text.
 
std::string GenerateCompleteHelp () const
 Generate complete help text (all commands)
 
absl::Status Execute (const std::string &name, const std::vector< std::string > &args, Rom *rom_context=nullptr)
 Execute a command by name.
 
bool HasCommand (const std::string &name) const
 Check if command exists.
 
size_t Count () const
 Get total command count.
 

Static Public Member Functions

static CommandRegistryInstance ()
 

Private Member Functions

 CommandRegistry ()=default
 
void RegisterAllCommands ()
 

Private Attributes

std::map< std::string, std::unique_ptr< resources::CommandHandler > > handlers_
 
std::map< std::string, CommandMetadatametadata_
 
std::map< std::string, std::string > aliases_
 

Detailed Description

Single source of truth for all z3ed commands.

Serves as the central registry for:

  • CLI command routing
  • Agent tool calling
  • Help text generation
  • TUI menu generation
  • Function schema export (for AI)

Ensures consistency: if a command exists, it's available to both human users (CLI) and AI agents (tool calling).

Definition at line 29 of file command_registry.h.

Constructor & Destructor Documentation

◆ CommandRegistry()

yaze::cli::CommandRegistry::CommandRegistry ( )
privatedefault

Member Function Documentation

◆ Instance()

◆ Register()

void yaze::cli::CommandRegistry::Register ( std::unique_ptr< resources::CommandHandler handler,
const CommandMetadata metadata 
)

Register a command handler.

Definition at line 21 of file command_registry.cc.

References yaze::cli::CommandRegistry::CommandMetadata::aliases, aliases_, handlers_, and metadata_.

Referenced by RegisterAllCommands().

◆ Get()

resources::CommandHandler * yaze::cli::CommandRegistry::Get ( const std::string &  name) const

Get a command handler by name or alias.

Definition at line 37 of file command_registry.cc.

References aliases_, and handlers_.

Referenced by Execute(), and HasCommand().

◆ GetMetadata()

const CommandRegistry::CommandMetadata * yaze::cli::CommandRegistry::GetMetadata ( const std::string &  name) const

Get command metadata.

Definition at line 56 of file command_registry.cc.

References aliases_, and metadata_.

Referenced by GenerateCategoryHelp(), and GenerateHelp().

◆ GetCommandsInCategory()

std::vector< std::string > yaze::cli::CommandRegistry::GetCommandsInCategory ( const std::string &  category) const

Get all commands in a category.

Definition at line 69 of file command_registry.cc.

References metadata_.

Referenced by GenerateCategoryHelp().

◆ GetCategories()

std::vector< std::string > yaze::cli::CommandRegistry::GetCategories ( ) const

Get all categories.

Definition at line 80 of file command_registry.cc.

References metadata_.

Referenced by GenerateCompleteHelp().

◆ GetAgentCommands()

std::vector< std::string > yaze::cli::CommandRegistry::GetAgentCommands ( ) const

Get all commands available to AI agents.

Definition at line 90 of file command_registry.cc.

References metadata_.

◆ ExportFunctionSchemas()

std::string yaze::cli::CommandRegistry::ExportFunctionSchemas ( ) const

Export function schemas for AI tool calling (JSON)

Todo:
Generate JSON function schemas from metadata

Definition at line 100 of file command_registry.cc.

◆ GenerateHelp()

std::string yaze::cli::CommandRegistry::GenerateHelp ( const std::string &  name) const

Generate help text for a command.

Definition at line 106 of file command_registry.cc.

References GetMetadata().

Here is the call graph for this function:

◆ GenerateCategoryHelp()

std::string yaze::cli::CommandRegistry::GenerateCategoryHelp ( const std::string &  category) const

Generate category help text.

Definition at line 139 of file command_registry.cc.

References GetCommandsInCategory(), and GetMetadata().

Referenced by GenerateCompleteHelp().

Here is the call graph for this function:

◆ GenerateCompleteHelp()

std::string yaze::cli::CommandRegistry::GenerateCompleteHelp ( ) const

Generate complete help text (all commands)

Definition at line 163 of file command_registry.cc.

References GenerateCategoryHelp(), and GetCategories().

Here is the call graph for this function:

◆ Execute()

absl::Status yaze::cli::CommandRegistry::Execute ( const std::string &  name,
const std::vector< std::string > &  args,
Rom rom_context = nullptr 
)

Execute a command by name.

Definition at line 175 of file command_registry.cc.

References Get().

Here is the call graph for this function:

◆ HasCommand()

bool yaze::cli::CommandRegistry::HasCommand ( const std::string &  name) const

Check if command exists.

Definition at line 186 of file command_registry.cc.

References Get().

Here is the call graph for this function:

◆ Count()

size_t yaze::cli::CommandRegistry::Count ( ) const
inline

Get total command count.

Definition at line 112 of file command_registry.h.

References handlers_.

◆ RegisterAllCommands()

Member Data Documentation

◆ handlers_

std::map<std::string, std::unique_ptr<resources::CommandHandler> > yaze::cli::CommandRegistry::handlers_
private

Definition at line 118 of file command_registry.h.

Referenced by Count(), Get(), and Register().

◆ metadata_

std::map<std::string, CommandMetadata> yaze::cli::CommandRegistry::metadata_
private

◆ aliases_

std::map<std::string, std::string> yaze::cli::CommandRegistry::aliases_
private

Definition at line 120 of file command_registry.h.

Referenced by Get(), GetMetadata(), and Register().


The documentation for this class was generated from the following files: