4#include "absl/strings/str_join.h"
5#include "absl/strings/str_cat.h"
6#include "ftxui/dom/elements.hpp"
7#include "ftxui/dom/table.hpp"
19 for (
auto& handler : handlers) {
20 commands_[handler->GetName()] = std::move(handler);
27 return absl::OkStatus();
30 std::vector<std::string> args;
31 for (
int i = 1; i < argc; ++i) {
32 args.push_back(argv[i]);
36 if (args[0] ==
"--tui") {
40 if (!rom_status.ok()) {
47 return absl::OkStatus();
50 if (args[0] ==
"help") {
51 if (args.size() > 1) {
56 return absl::OkStatus();
61 std::vector<std::string> command_args(args.begin() + 1, args.end());
62 return it->second->Run(command_args,
nullptr);
65 return absl::NotFoundError(absl::StrCat(
"Unknown command: ", args[0]));
69 using namespace ftxui;
70 auto banner = text(
"🎮 Z3ED - CLI for Zelda 3") | bold | center;
71 auto summary = Table({
72 {
"Command",
"Description",
"TODO/Reference"},
73 {
"agent",
"AI conversational agent",
"ref: agent::chat"},
74 {
"rom",
"ROM info, diff, validate",
"todo#101"},
75 {
"dungeon",
"Dungeon tooling",
"todo#202"},
76 {
"gfx",
"Graphics export/import",
"ref: gfx::export"},
77 {
"palette",
"Palette operations",
"todo#305"},
78 {
"project",
"Project workflows",
"ref: project::build"}
80 summary.SelectAll().Border(LIGHT);
81 summary.SelectRow(0).Decorate(bold);
89 text(
"Try `z3ed --tui` for the animated FTXUI interface") | center,
90 text(
"Use `--list-commands` for complete breakdown") | dim | center
93 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(layout));
94 Render(screen, layout);
99 using namespace ftxui;
100 std::vector<std::vector<std::string>> rows;
101 rows.push_back({
"Subcommand",
"Summary",
"TODO/Reference"});
105 const auto& metadata = it->second->Describe();
106 for (
const auto& entry : metadata.entries) {
107 rows.push_back({entry.name, entry.description, entry.todo_reference});
111 if (rows.size() == 1) {
112 rows.push_back({
"—",
"No metadata registered",
"—"});
116 detail.SelectAll().Border(LIGHT);
117 detail.SelectRow(0).Decorate(bold);
120 text(absl::StrCat(
"Category: ", category)) | bold | center,
124 text(
"Command handlers can expose TODO references via Describe().") | dim | center
127 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(layout));
128 Render(screen, layout);
133 using namespace ftxui;
134 std::vector<Element> tiles;
135 for (
const auto& [name, handler] :
commands_) {
136 const auto summary = handler->Describe();
139 text(summary.display_name.empty() ? name : summary.display_name) | bold,
141 text(summary.summary),
142 text(absl::StrCat(
"TODO: ", summary.todo_reference)) | dim
147 text(
"Z3ED Command Summary") | bold | center,
149 tiles.empty() ? text(
"No commands registered.") | dim | center
152 text(
"Use `z3ed --tui` for interactive command palette.") | center | dim
155 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(layout));
156 Render(screen, layout);
The Rom class is used to load, save, and modify Rom data.
absl::Status LoadFromFile(const std::string &filename, bool z3_load=true)
absl::Status Run(int argc, char *argv[])
void PrintCategoryHelp(const std::string &category) const
void PrintCommandSummary() const
void ShowCategoryHelp(const std::string &category) const
void ShowCommandSummary() const
std::map< std::string, std::unique_ptr< resources::CommandHandler > > commands_
void PrintTopLevelHelp() const
std::vector< std::unique_ptr< resources::CommandHandler > > CreateAllCommandHandlers()
Factory function to create all command handlers (CLI + agent)
std::string GetColoredLogo()
Main namespace for the application.