30 return absl::OkStatus();
33 std::vector<std::string> args;
34 for (
int i = 1; i < argc; ++i) {
35 args.push_back(argv[i]);
38 if (args[0] ==
"help") {
39 if (args.size() > 1) {
40 const std::string& target = args[1];
42 if (target ==
"all") {
43 std::cout << registry.GenerateCompleteHelp() <<
"\n";
44 }
else if (registry.HasCommand(target)) {
45 std::cout << registry.GenerateHelp(target) <<
"\n";
52 return absl::OkStatus();
56 if (args[0] ==
"agent") {
57 std::vector<std::string> agent_args(args.begin() + 1, args.end());
64 std::string command_name = args[0];
65 std::vector<std::string> command_args(args.begin() + 1, args.end());
67 if (registry.HasCommand(command_name)) {
68 return registry.Execute(command_name, command_args,
nullptr);
71 return absl::NotFoundError(absl::StrCat(
"Unknown command: ", command_name));
76 auto categories = registry.GetCategories();
79 using namespace ftxui;
81 auto banner = text(
"🎮 Z3ED - AI-Powered ROM Editor CLI") | bold | center;
83 std::vector<std::vector<std::string>> rows;
84 rows.push_back({
"Category",
"Commands",
"Description"});
87 rows.push_back({
"agent",
"chat, learn, todo, emulator-*",
88 "AI conversational agent + debugging tools"});
91 for (
const auto& category : categories) {
92 auto commands = registry.GetCommandsInCategory(category);
93 std::string cmd_list = commands.size() > 3
94 ? absl::StrCat(commands.size(),
" commands")
95 : absl::StrJoin(commands,
", ");
98 if (category ==
"resource")
99 desc =
"ROM resource inspection";
100 else if (category ==
"dungeon")
101 desc =
"Dungeon editing";
102 else if (category ==
"overworld")
103 desc =
"Overworld editing";
104 else if (category ==
"emulator")
105 desc =
"Emulator debugging";
106 else if (category ==
"graphics")
107 desc =
"Graphics/palette/sprites";
108 else if (category ==
"game")
109 desc =
"Messages/dialogue/music";
111 desc = category +
" commands";
113 rows.push_back({category, cmd_list, desc});
117 summary.SelectAll().Border(LIGHT);
118 summary.SelectRow(0).Decorate(bold);
123 text(absl::StrFormat(
"Total: %zu commands across %zu categories",
124 registry.Count(), categories.size() + 1)) |
126 text(
"Try `z3ed agent simple-chat` for AI-powered ROM inspection") |
128 text(
"Use `z3ed --list-commands` for complete list") | dim | center});
130 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(layout));
131 Render(screen, layout);
136 std::cout <<
"Z3ED - AI-Powered ROM Editor CLI\n\n";
137 std::cout <<
"Categories:\n";
138 std::cout <<
" agent - AI conversational agent + debugging tools\n";
139 for (
const auto& category : categories) {
140 auto commands = registry.GetCommandsInCategory(category);
141 std::cout <<
" " << category <<
" - " << commands.size() <<
" commands\n";
143 std::cout <<
"\nTotal: " << registry.Count() <<
" commands\n";
144 std::cout <<
"Use 'help <category>' for more details.\n";
150 auto commands = registry.GetCommandsInCategory(category);
152#ifndef __EMSCRIPTEN__
153 using namespace ftxui;
155 std::vector<std::vector<std::string>> rows;
156 rows.push_back({
"Command",
"Description",
"Requirements"});
158 for (
const auto& cmd_name : commands) {
159 auto* metadata = registry.GetMetadata(cmd_name);
161 std::string requirements;
162 if (metadata->requires_rom)
163 requirements +=
"ROM ";
164 if (metadata->requires_grpc)
165 requirements +=
"gRPC ";
166 if (requirements.empty())
167 requirements =
"—";
169 rows.push_back({cmd_name, metadata->description, requirements});
173 if (rows.size() == 1) {
174 rows.push_back({
"—",
"No commands in this category",
"—"});
178 detail.SelectAll().Border(LIGHT);
179 detail.SelectRow(0).Decorate(bold);
182 vbox({text(absl::StrCat(
"Category: ", category)) | bold | center,
183 separator(), detail.Render(), separator(),
184 text(
"Commands are auto-registered from CommandRegistry") | dim |
187 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(layout));
188 Render(screen, layout);
192 std::cout <<
"Category: " << category <<
"\n\n";
193 for (
const auto& cmd_name : commands) {
194 auto* metadata = registry.GetMetadata(cmd_name);
196 std::cout <<
" " << cmd_name <<
" - " << metadata->description <<
"\n";
199 if (commands.empty()) {
200 std::cout <<
" No commands in this category.\n";
207 auto categories = registry.GetCategories();
209#ifndef __EMSCRIPTEN__
210 using namespace ftxui;
212 std::vector<std::vector<std::string>> rows;
213 rows.push_back({
"Command",
"Category",
"Description"});
215 for (
const auto& category : categories) {
216 auto commands = registry.GetCommandsInCategory(category);
217 for (
const auto& cmd_name : commands) {
218 auto* metadata = registry.GetMetadata(cmd_name);
220 rows.push_back({cmd_name, metadata->category, metadata->description});
225 if (rows.size() == 1) {
226 rows.push_back({
"—",
"—",
"No commands registered"});
229 Table command_table(rows);
230 command_table.SelectAll().Border(LIGHT);
231 command_table.SelectRow(0).Decorate(bold);
234 vbox({text(
"Z3ED Command Summary") | bold | center, separator(),
235 command_table.Render(), separator(),
236 text(absl::StrFormat(
"Total: %zu commands across %zu categories",
237 registry.Count(), categories.size())) |
239 text(
"Use `z3ed --tui` for interactive command palette.") | center |
242 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(layout));
243 Render(screen, layout);
247 std::cout <<
"Z3ED Command Summary\n\n";
248 for (
const auto& category : categories) {
249 auto commands = registry.GetCommandsInCategory(category);
250 for (
const auto& cmd_name : commands) {
251 auto* metadata = registry.GetMetadata(cmd_name);
253 std::cout <<
" " << cmd_name <<
" [" << metadata->category <<
"] - "
254 << metadata->description <<
"\n";
258 std::cout <<
"\nTotal: " << registry.Count() <<
" commands across "
259 << categories.size() <<
" categories\n";