yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
command_handlers.cc
Go to the documentation of this file.
2
5#ifdef YAZE_WITH_GRPC
7#endif
16
17#include <memory>
18#include <unordered_map>
19
20namespace yaze {
21namespace cli {
22namespace handlers {
23
24// Static command registry
25namespace {
26std::unordered_map<std::string, resources::CommandHandler*> g_command_registry;
27}
28
29std::vector<std::unique_ptr<resources::CommandHandler>> CreateCliCommandHandlers() {
30 std::vector<std::unique_ptr<resources::CommandHandler>> handlers;
31
32 // Graphics commands
33 handlers.push_back(std::make_unique<HexReadCommandHandler>());
34 handlers.push_back(std::make_unique<HexWriteCommandHandler>());
35 handlers.push_back(std::make_unique<HexSearchCommandHandler>());
36
37 // Palette commands
38 handlers.push_back(std::make_unique<PaletteGetColorsCommandHandler>());
39 handlers.push_back(std::make_unique<PaletteSetColorCommandHandler>());
40 handlers.push_back(std::make_unique<PaletteAnalyzeCommandHandler>());
41
42 // Sprite commands
43 handlers.push_back(std::make_unique<SpriteListCommandHandler>());
44 handlers.push_back(std::make_unique<SpritePropertiesCommandHandler>());
45 handlers.push_back(std::make_unique<SpritePaletteCommandHandler>());
46
47 // Music commands
48 handlers.push_back(std::make_unique<MusicListCommandHandler>());
49 handlers.push_back(std::make_unique<MusicInfoCommandHandler>());
50 handlers.push_back(std::make_unique<MusicTracksCommandHandler>());
51
52 // Dialogue commands
53 handlers.push_back(std::make_unique<DialogueListCommandHandler>());
54 handlers.push_back(std::make_unique<DialogueReadCommandHandler>());
55 handlers.push_back(std::make_unique<DialogueSearchCommandHandler>());
56
57 // Message commands
58 handlers.push_back(std::make_unique<MessageListCommandHandler>());
59 handlers.push_back(std::make_unique<MessageReadCommandHandler>());
60 handlers.push_back(std::make_unique<MessageSearchCommandHandler>());
61
62 return handlers;
63}
64
66
67std::vector<std::unique_ptr<resources::CommandHandler>> CreateAgentCommandHandlers() {
68 std::vector<std::unique_ptr<resources::CommandHandler>> handlers;
69
70 // Add simple-chat command handler
71 handlers.push_back(std::make_unique<SimpleChatCommandHandler>());
72
73 // Resource inspection tools
74 handlers.push_back(std::make_unique<ResourceListCommandHandler>());
75 handlers.push_back(std::make_unique<ResourceSearchCommandHandler>());
76
77 // Dungeon inspection
78 handlers.push_back(std::make_unique<DungeonListSpritesCommandHandler>());
79 handlers.push_back(std::make_unique<DungeonDescribeRoomCommandHandler>());
80 handlers.push_back(std::make_unique<DungeonExportRoomCommandHandler>());
81 handlers.push_back(std::make_unique<DungeonListObjectsCommandHandler>());
82 handlers.push_back(std::make_unique<DungeonGetRoomTilesCommandHandler>());
83 handlers.push_back(std::make_unique<DungeonSetRoomPropertyCommandHandler>());
84
85 // Overworld inspection
86 handlers.push_back(std::make_unique<OverworldFindTileCommandHandler>());
87 handlers.push_back(std::make_unique<OverworldDescribeMapCommandHandler>());
88 handlers.push_back(std::make_unique<OverworldListWarpsCommandHandler>());
89 handlers.push_back(std::make_unique<OverworldListSpritesCommandHandler>());
90 handlers.push_back(std::make_unique<OverworldGetEntranceCommandHandler>());
91 handlers.push_back(std::make_unique<OverworldTileStatsCommandHandler>());
92
93 // GUI automation tools
94 handlers.push_back(std::make_unique<GuiPlaceTileCommandHandler>());
95 handlers.push_back(std::make_unique<GuiClickCommandHandler>());
96 handlers.push_back(std::make_unique<GuiDiscoverToolCommandHandler>());
97 handlers.push_back(std::make_unique<GuiScreenshotCommandHandler>());
98
99 // Emulator & debugger commands
100#ifdef YAZE_WITH_GRPC
101 handlers.push_back(std::make_unique<EmulatorStepCommandHandler>());
102 handlers.push_back(std::make_unique<EmulatorRunCommandHandler>());
103 handlers.push_back(std::make_unique<EmulatorPauseCommandHandler>());
104 handlers.push_back(std::make_unique<EmulatorResetCommandHandler>());
105 handlers.push_back(std::make_unique<EmulatorGetStateCommandHandler>());
106 handlers.push_back(std::make_unique<EmulatorSetBreakpointCommandHandler>());
107 handlers.push_back(std::make_unique<EmulatorClearBreakpointCommandHandler>());
108 handlers.push_back(std::make_unique<EmulatorListBreakpointsCommandHandler>());
109 handlers.push_back(std::make_unique<EmulatorReadMemoryCommandHandler>());
110 handlers.push_back(std::make_unique<EmulatorWriteMemoryCommandHandler>());
111 handlers.push_back(std::make_unique<EmulatorGetRegistersCommandHandler>());
112 handlers.push_back(std::make_unique<EmulatorGetMetricsCommandHandler>());
113#endif
114
115 return handlers;
116}
117
118std::vector<std::unique_ptr<resources::CommandHandler>> CreateAllCommandHandlers() {
119 std::vector<std::unique_ptr<resources::CommandHandler>> handlers;
120
121 // Add CLI handlers
122 auto cli_handlers = CreateCliCommandHandlers();
123 for (auto& handler : cli_handlers) {
124 handlers.push_back(std::move(handler));
125 }
126
127 // Add agent handlers
128 auto agent_handlers = CreateAgentCommandHandlers();
129 for (auto& handler : agent_handlers) {
130 handlers.push_back(std::move(handler));
131 }
132
133 return handlers;
134}
135
137 auto it = g_command_registry.find(name);
138 if (it != g_command_registry.end()) {
139 return it->second;
140 }
141 return nullptr;
142}
143
144} // namespace handlers
145} // namespace cli
146} // namespace yaze
147
Base class for CLI command handlers.
std::unordered_map< std::string, resources::CommandHandler * > g_command_registry
std::vector< std::unique_ptr< resources::CommandHandler > > CreateAllCommandHandlers()
Factory function to create all command handlers (CLI + agent)
std::vector< std::unique_ptr< resources::CommandHandler > > CreateCliCommandHandlers()
Factory function to create all CLI-level command handlers.
resources::CommandHandler * GetCommandHandler(const std::string &name)
Get a command handler by name.
std::vector< std::unique_ptr< resources::CommandHandler > > CreateAgentCommandHandlers()
Factory function to create all agent-specific command handlers.
Main namespace for the application.