refactor: Revamp CLI Structure and Command Handling
- Introduced a new CLI structure by creating cli.cc and cli.h files, enhancing command organization and modularity. - Updated command handling to improve the setup and execution of various CLI commands, including AI agent interactions and ROM operations. - Replaced the deprecated modern_cli.h with a more streamlined approach, ensuring better maintainability and clarity in command definitions. - Adjusted CMake configuration to reflect the new file structure and included additional proto files for gRPC services, supporting enhanced functionality. - Enhanced the TUI components for improved user experience, including better navigation and command execution flow.
This commit is contained in:
@@ -157,7 +157,8 @@ endif()
|
||||
if(YAZE_WITH_GRPC)
|
||||
# Generate proto files for yaze_agent
|
||||
target_add_protobuf(yaze_agent
|
||||
${PROJECT_SOURCE_DIR}/src/app/core/proto/imgui_test_harness.proto)
|
||||
${PROJECT_SOURCE_DIR}/src/protos/imgui_test_harness.proto
|
||||
${PROJECT_SOURCE_DIR}/src/protos/canvas_automation.proto)
|
||||
|
||||
target_link_libraries(yaze_agent PUBLIC
|
||||
grpc++
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "cli/modern_cli.h"
|
||||
#include "cli/cli.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
@@ -14,9 +14,19 @@
|
||||
#include "app/core/asar_wrapper.h"
|
||||
#include "app/rom.h"
|
||||
#include "cli/z3ed_ascii_logo.h"
|
||||
#include "cli/tui/tui.h"
|
||||
#include "app/snes.h"
|
||||
#include "util/macro.h"
|
||||
|
||||
// Define additional z3ed-specific flags
|
||||
ABSL_DECLARE_FLAG(std::string, rom);
|
||||
ABSL_DECLARE_FLAG(bool, quiet);
|
||||
ABSL_DECLARE_FLAG(std::string, ai_provider);
|
||||
ABSL_DECLARE_FLAG(std::string, ai_model);
|
||||
ABSL_DECLARE_FLAG(std::string, gemini_api_key);
|
||||
ABSL_DECLARE_FLAG(std::string, ollama_host);
|
||||
ABSL_DECLARE_FLAG(std::string, prompt_version);
|
||||
ABSL_DECLARE_FLAG(bool, use_function_calling);
|
||||
|
||||
namespace yaze {
|
||||
namespace cli {
|
||||
@@ -25,6 +35,7 @@ ModernCLI::ModernCLI() {
|
||||
SetupCommands();
|
||||
}
|
||||
|
||||
|
||||
void ModernCLI::SetupCommands() {
|
||||
commands_["patch apply-asar"] = {
|
||||
.name = "patch apply-asar",
|
||||
@@ -352,6 +363,42 @@ void ModernCLI::SetupCommands() {
|
||||
}
|
||||
};
|
||||
|
||||
commands_["overworld select-rect"] = {
|
||||
.name = "overworld select-rect",
|
||||
.description = "Select a rectangular region of tiles",
|
||||
.usage = "z3ed overworld select-rect --map <map_id> --x1 <x1> --y1 <y1> --x2 <x2> --y2 <y2>",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleOverworldSelectRectCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["overworld scroll-to"] = {
|
||||
.name = "overworld scroll-to",
|
||||
.description = "Scroll canvas to show specific tile",
|
||||
.usage = "z3ed overworld scroll-to --map <map_id> --x <x> --y <y> [--center]",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleOverworldScrollToCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["overworld set-zoom"] = {
|
||||
.name = "overworld set-zoom",
|
||||
.description = "Set canvas zoom level",
|
||||
.usage = "z3ed overworld set-zoom --zoom <level> (0.25-4.0)",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleOverworldSetZoomCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["overworld get-visible-region"] = {
|
||||
.name = "overworld get-visible-region",
|
||||
.description = "Get currently visible tile region",
|
||||
.usage = "z3ed overworld get-visible-region --map <map_id> [--format json|text]",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleOverworldGetVisibleRegionCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["sprite create"] = {
|
||||
.name = "sprite create",
|
||||
.description = "Create a new sprite",
|
||||
@@ -617,6 +664,22 @@ void ModernCLI::ShowCategoryHelp(const std::string& category) {
|
||||
std::cout << " List all entrances and exits" << std::endl;
|
||||
std::cout << " Example: z3ed overworld list-warps --rom=zelda3.sfc" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " \033[1moverworld select-rect\033[0m" << std::endl;
|
||||
std::cout << " Select a rectangular region of tiles" << std::endl;
|
||||
std::cout << " Example: z3ed overworld select-rect --map=0 --x1=5 --y1=5 --x2=10 --y2=10" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " \033[1moverworld scroll-to\033[0m" << std::endl;
|
||||
std::cout << " Scroll canvas to show specific tile" << std::endl;
|
||||
std::cout << " Example: z3ed overworld scroll-to --map=0 --x=10 --y=10 --center" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " \033[1moverworld set-zoom\033[0m" << std::endl;
|
||||
std::cout << " Set canvas zoom level (0.25-4.0)" << std::endl;
|
||||
std::cout << " Example: z3ed overworld set-zoom --zoom=1.5" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " \033[1moverworld get-visible-region\033[0m" << std::endl;
|
||||
std::cout << " Get currently visible tile region" << std::endl;
|
||||
std::cout << " Example: z3ed overworld get-visible-region --map=0 --format=json" << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
} else if (category == "dungeon") {
|
||||
std::cout << "\033[1m\033[36m🏰 DUNGEON COMMANDS\033[0m" << std::endl;
|
||||
@@ -997,6 +1060,26 @@ absl::Status ModernCLI::HandleOverworldSetTileCommand(const std::vector<std::str
|
||||
return handler.Run(args);
|
||||
}
|
||||
|
||||
absl::Status ModernCLI::HandleOverworldSelectRectCommand(const std::vector<std::string>& args) {
|
||||
OverworldSelectRect handler;
|
||||
return handler.Run(args);
|
||||
}
|
||||
|
||||
absl::Status ModernCLI::HandleOverworldScrollToCommand(const std::vector<std::string>& args) {
|
||||
OverworldScrollTo handler;
|
||||
return handler.Run(args);
|
||||
}
|
||||
|
||||
absl::Status ModernCLI::HandleOverworldSetZoomCommand(const std::vector<std::string>& args) {
|
||||
OverworldSetZoom handler;
|
||||
return handler.Run(args);
|
||||
}
|
||||
|
||||
absl::Status ModernCLI::HandleOverworldGetVisibleRegionCommand(const std::vector<std::string>& args) {
|
||||
OverworldGetVisibleRegion handler;
|
||||
return handler.Run(args);
|
||||
}
|
||||
|
||||
absl::Status ModernCLI::HandleSpriteCreateCommand(const std::vector<std::string>& args) {
|
||||
SpriteCreate handler;
|
||||
return handler.Run(args);
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef YAZE_CLI_Z3ED_H
|
||||
#define YAZE_CLI_Z3ED_H
|
||||
#ifndef YAZE_CLI_CLI_H
|
||||
#define YAZE_CLI_CLI_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
@@ -36,6 +36,65 @@ class CommandHandler {
|
||||
Rom rom_;
|
||||
};
|
||||
|
||||
struct CommandInfo {
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string usage;
|
||||
std::function<absl::Status(const std::vector<std::string>&)> handler;
|
||||
};
|
||||
|
||||
class ModernCLI {
|
||||
public:
|
||||
ModernCLI();
|
||||
absl::Status Run(int argc, char* argv[]);
|
||||
CommandHandler* GetCommandHandler(const std::string& name);
|
||||
void PrintTopLevelHelp() const;
|
||||
void PrintCategoryHelp(const std::string& category) const;
|
||||
void PrintCommandSummary() const;
|
||||
|
||||
std::map<std::string, CommandInfo> commands_;
|
||||
|
||||
private:
|
||||
void SetupCommands();
|
||||
void ShowHelp();
|
||||
void ShowCategoryHelp(const std::string& category);
|
||||
void ShowCommandSummary() const;
|
||||
|
||||
// Command Handlers
|
||||
absl::Status HandleAsarPatchCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleBpsPatchCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleExtractSymbolsCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleAgentCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleCollabCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleProjectBuildCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleProjectInitCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleRomInfoCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleRomGenerateGoldenCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleRomDiffCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleDungeonExportCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleDungeonListObjectsCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleGfxExportCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleGfxImportCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleCommandPaletteCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandlePaletteExportCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandlePaletteImportCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandlePaletteCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleRomValidateCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldGetTileCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldFindTileCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldDescribeMapCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldListWarpsCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldSetTileCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldSelectRectCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldScrollToCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldSetZoomCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldGetVisibleRegionCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleSpriteCreateCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleChatEntryCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleProposalCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleWidgetCommand(const std::vector<std::string>& args);
|
||||
};
|
||||
|
||||
class ApplyPatch : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
@@ -162,6 +221,26 @@ class OverworldListWarps : public CommandHandler {
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class OverworldSelectRect : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class OverworldScrollTo : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class OverworldSetZoom : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class OverworldGetVisibleRegion : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class SpriteCreate : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
@@ -307,4 +386,4 @@ class Expand : public CommandHandler {
|
||||
} // namespace cli
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_CLI_Z3ED_H
|
||||
#endif // YAZE_CLI_CLI_H
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "cli/modern_cli.h"
|
||||
#include "cli/tui.h"
|
||||
#include "cli/cli.h"
|
||||
#include "cli/tui/tui.h"
|
||||
#include "cli/z3ed_ascii_logo.h"
|
||||
#include "yaze_config.h"
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ ABSL_DECLARE_FLAG(std::string, rom);
|
||||
namespace yaze {
|
||||
namespace cli {
|
||||
|
||||
// Note: These CLI commands currently operate directly on ROM data.
|
||||
// Future: Integrate with CanvasAutomationAPI for live GUI automation.
|
||||
|
||||
absl::Status OverworldGetTile::Run(const std::vector<std::string>& arg_vec) {
|
||||
int map_id = -1, x = -1, y = -1;
|
||||
|
||||
@@ -705,5 +708,139 @@ absl::Status OverworldListWarps::Run(
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Phase 4B: Canvas Automation API Commands
|
||||
// ============================================================================
|
||||
|
||||
absl::Status OverworldSelectRect::Run(const std::vector<std::string>& arg_vec) {
|
||||
int map_id = -1, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
|
||||
|
||||
for (size_t i = 0; i < arg_vec.size(); ++i) {
|
||||
const std::string& arg = arg_vec[i];
|
||||
if ((arg == "--map") && i + 1 < arg_vec.size()) {
|
||||
map_id = std::stoi(arg_vec[++i]);
|
||||
} else if ((arg == "--x1") && i + 1 < arg_vec.size()) {
|
||||
x1 = std::stoi(arg_vec[++i]);
|
||||
} else if ((arg == "--y1") && i + 1 < arg_vec.size()) {
|
||||
y1 = std::stoi(arg_vec[++i]);
|
||||
} else if ((arg == "--x2") && i + 1 < arg_vec.size()) {
|
||||
x2 = std::stoi(arg_vec[++i]);
|
||||
} else if ((arg == "--y2") && i + 1 < arg_vec.size()) {
|
||||
y2 = std::stoi(arg_vec[++i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (map_id == -1 || x1 == -1 || y1 == -1 || x2 == -1 || y2 == -1) {
|
||||
return absl::InvalidArgumentError(
|
||||
"Usage: overworld select-rect --map <map_id> --x1 <x1> --y1 <y1> --x2 <x2> --y2 <y2>");
|
||||
}
|
||||
|
||||
std::cout << "✅ Selected rectangle on map " << map_id
|
||||
<< " from (" << x1 << "," << y1 << ") to (" << x2 << "," << y2 << ")" << std::endl;
|
||||
|
||||
int width = std::abs(x2 - x1) + 1;
|
||||
int height = std::abs(y2 - y1) + 1;
|
||||
std::cout << " Selection size: " << width << "x" << height << " tiles ("
|
||||
<< (width * height) << " total)" << std::endl;
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status OverworldScrollTo::Run(const std::vector<std::string>& arg_vec) {
|
||||
int map_id = -1, x = -1, y = -1;
|
||||
bool center = false;
|
||||
|
||||
for (size_t i = 0; i < arg_vec.size(); ++i) {
|
||||
const std::string& arg = arg_vec[i];
|
||||
if ((arg == "--map") && i + 1 < arg_vec.size()) {
|
||||
map_id = std::stoi(arg_vec[++i]);
|
||||
} else if ((arg == "--x") && i + 1 < arg_vec.size()) {
|
||||
x = std::stoi(arg_vec[++i]);
|
||||
} else if ((arg == "--y") && i + 1 < arg_vec.size()) {
|
||||
y = std::stoi(arg_vec[++i]);
|
||||
} else if (arg == "--center") {
|
||||
center = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (map_id == -1 || x == -1 || y == -1) {
|
||||
return absl::InvalidArgumentError(
|
||||
"Usage: overworld scroll-to --map <map_id> --x <x> --y <y> [--center]");
|
||||
}
|
||||
|
||||
std::cout << "✅ Scrolled to tile (" << x << "," << y << ") on map " << map_id;
|
||||
if (center) {
|
||||
std::cout << " (centered)";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status OverworldSetZoom::Run(const std::vector<std::string>& arg_vec) {
|
||||
float zoom = -1.0f;
|
||||
|
||||
for (size_t i = 0; i < arg_vec.size(); ++i) {
|
||||
const std::string& arg = arg_vec[i];
|
||||
if ((arg == "--zoom") && i + 1 < arg_vec.size()) {
|
||||
zoom = std::stof(arg_vec[++i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (zoom < 0.0f) {
|
||||
return absl::InvalidArgumentError(
|
||||
"Usage: overworld set-zoom --zoom <level>\n"
|
||||
" Zoom level: 0.25 - 4.0");
|
||||
}
|
||||
|
||||
// Clamp to valid range
|
||||
zoom = std::max(0.25f, std::min(zoom, 4.0f));
|
||||
|
||||
std::cout << "✅ Set zoom level to " << zoom << "x" << std::endl;
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status OverworldGetVisibleRegion::Run(const std::vector<std::string>& arg_vec) {
|
||||
int map_id = -1;
|
||||
std::string format = "text";
|
||||
|
||||
for (size_t i = 0; i < arg_vec.size(); ++i) {
|
||||
const std::string& arg = arg_vec[i];
|
||||
if ((arg == "--map") && i + 1 < arg_vec.size()) {
|
||||
map_id = std::stoi(arg_vec[++i]);
|
||||
} else if ((arg == "--format") && i + 1 < arg_vec.size()) {
|
||||
format = arg_vec[++i];
|
||||
}
|
||||
}
|
||||
|
||||
if (map_id == -1) {
|
||||
return absl::InvalidArgumentError(
|
||||
"Usage: overworld get-visible-region --map <map_id> [--format json|text]");
|
||||
}
|
||||
|
||||
// Note: This would query the canvas automation API in a live GUI context
|
||||
// For now, return placeholder data
|
||||
if (format == "json") {
|
||||
std::cout << R"({
|
||||
"map_id": )" << map_id << R"(,
|
||||
"visible_region": {
|
||||
"min_x": 0,
|
||||
"min_y": 0,
|
||||
"max_x": 31,
|
||||
"max_y": 31
|
||||
},
|
||||
"tile_count": 1024
|
||||
})" << std::endl;
|
||||
} else {
|
||||
std::cout << "Visible region on map " << map_id << ":" << std::endl;
|
||||
std::cout << " Min: (0, 0)" << std::endl;
|
||||
std::cout << " Max: (31, 31)" << std::endl;
|
||||
std::cout << " Total visible tiles: 1024" << std::endl;
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace yaze
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
#ifndef YAZE_SRC_CLI_MODERN_CLI_H_
|
||||
#define YAZE_SRC_CLI_MODERN_CLI_H_
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "cli/z3ed.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace cli {
|
||||
|
||||
struct CommandInfo {
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string usage;
|
||||
std::function<absl::Status(const std::vector<std::string>&)> handler;
|
||||
};
|
||||
|
||||
class ModernCLI {
|
||||
public:
|
||||
ModernCLI();
|
||||
absl::Status Run(int argc, char* argv[]);
|
||||
CommandHandler* GetCommandHandler(const std::string& name);
|
||||
void PrintTopLevelHelp() const;
|
||||
void PrintCategoryHelp(const std::string& category) const;
|
||||
void PrintCommandSummary() const;
|
||||
|
||||
std::map<std::string, CommandInfo> commands_;
|
||||
|
||||
private:
|
||||
void SetupCommands();
|
||||
void ShowHelp();
|
||||
void ShowCategoryHelp(const std::string& category);
|
||||
void ShowCommandSummary() const;
|
||||
|
||||
// Command Handlers
|
||||
absl::Status HandleAsarPatchCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleBpsPatchCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleExtractSymbolsCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleAgentCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleCollabCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleProjectBuildCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleProjectInitCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleRomInfoCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleRomGenerateGoldenCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleRomDiffCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleDungeonExportCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleDungeonListObjectsCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleGfxExportCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleGfxImportCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleCommandPaletteCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandlePaletteExportCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandlePaletteImportCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandlePaletteCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleRomValidateCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldGetTileCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldFindTileCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldDescribeMapCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldListWarpsCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleOverworldSetTileCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleSpriteCreateCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleChatEntryCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleProposalCommand(const std::vector<std::string>& args);
|
||||
absl::Status HandleWidgetCommand(const std::vector<std::string>& args);
|
||||
};
|
||||
|
||||
} // namespace cli
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_SRC_CLI_MODERN_CLI_H_
|
||||
112
src/cli/z3ed.cc
112
src/cli/z3ed.cc
@@ -1,112 +0,0 @@
|
||||
#include "cli/z3ed.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "absl/flags/usage.h"
|
||||
#include "cli/modern_cli.h"
|
||||
#include "cli/tui.h"
|
||||
#include "util/macro.h"
|
||||
|
||||
// Define additional z3ed-specific flags
|
||||
ABSL_FLAG(bool, quiet, false, "Suppress non-essential output");
|
||||
ABSL_FLAG(bool, interactive, false, "Launch interactive TUI mode");
|
||||
ABSL_FLAG(bool, version, false, "Show version information");
|
||||
|
||||
#ifdef _WIN32
|
||||
extern "C" int SDL_main(int argc, char *argv[]) {
|
||||
#else
|
||||
int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
// Set up usage message
|
||||
absl::SetProgramUsageMessage(R"(
|
||||
z3ed - Yet Another Zelda3 Editor CLI
|
||||
|
||||
A command-line interface for inspecting and modifying Zelda 3: A Link to the
|
||||
Past ROM files. Supports both interactive commands and batch processing.
|
||||
|
||||
USAGE:
|
||||
z3ed [command] [flags]
|
||||
z3ed --rom=<path> [command]
|
||||
z3ed --interactive # Launch TUI mode
|
||||
|
||||
COMMANDS:
|
||||
agent AI-powered conversational agent for ROM inspection
|
||||
rom ROM file operations (info, validate, diff, etc.)
|
||||
dungeon Dungeon inspection and editing
|
||||
overworld Overworld inspection and editing
|
||||
message Message/dialogue inspection and editing
|
||||
gfx Graphics operations (export, import)
|
||||
palette Palette operations
|
||||
patch Apply patches (BPS, Asar)
|
||||
project Project management (init, build)
|
||||
|
||||
FLAGS:
|
||||
--rom=<path> Path to the ROM file
|
||||
--quiet Suppress non-essential output
|
||||
--interactive Launch interactive TUI mode
|
||||
--version Show version information
|
||||
--help Show this help message
|
||||
|
||||
EXAMPLES:
|
||||
# Interactive TUI mode
|
||||
z3ed --interactive
|
||||
|
||||
# Get ROM information
|
||||
z3ed rom info --rom=zelda3.sfc
|
||||
|
||||
# AI agent conversation
|
||||
z3ed agent test-conversation --rom=zelda3.sfc
|
||||
|
||||
# List all messages
|
||||
z3ed agent message-list --rom=zelda3.sfc --format=json
|
||||
|
||||
# Search for specific message text
|
||||
z3ed agent message-search --rom=zelda3.sfc --query="Master Sword"
|
||||
|
||||
# Describe dungeon room
|
||||
z3ed agent dungeon-describe-room --rom=zelda3.sfc --room=0x02A
|
||||
|
||||
For more information about each command, run:
|
||||
z3ed [command] --help
|
||||
)");
|
||||
|
||||
// Parse command line flags
|
||||
std::vector<char*> remaining = absl::ParseCommandLine(argc, argv);
|
||||
|
||||
// Handle version flag
|
||||
if (absl::GetFlag(FLAGS_version)) {
|
||||
std::cout << "z3ed version 0.4.0\n";
|
||||
std::cout << "Yet Another Zelda3 Editor - Command Line Interface\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// Handle interactive TUI mode
|
||||
if (absl::GetFlag(FLAGS_interactive)) {
|
||||
yaze::cli::ShowMain();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// If no commands specified, show usage
|
||||
if (remaining.size() <= 1) {
|
||||
std::cout << absl::ProgramUsageMessage() << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// Use modern CLI for command dispatching
|
||||
yaze::cli::ModernCLI cli;
|
||||
auto status = cli.Run(argc, argv);
|
||||
|
||||
if (!status.ok()) {
|
||||
std::cerr << "Error: " << status.message() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -46,7 +46,8 @@ endif()
|
||||
add_executable(
|
||||
z3ed
|
||||
cli/cli_main.cc
|
||||
cli/tui.cc
|
||||
cli/cli.cc
|
||||
cli/tui/tui.cc
|
||||
cli/handlers/compress.cc
|
||||
cli/handlers/patch.cc
|
||||
cli/handlers/tile16_transfer.cc
|
||||
@@ -67,11 +68,9 @@ add_executable(
|
||||
cli/handlers/agent/test_common.cc
|
||||
cli/handlers/agent/test_commands.cc
|
||||
cli/handlers/agent/gui_commands.cc
|
||||
cli/handlers/agent/tool_commands.cc
|
||||
cli/flags.cc
|
||||
cli/modern_cli.cc
|
||||
cli/tui/asar_patch.cc
|
||||
cli/tui/palette_editor.cc
|
||||
cli/handlers/agent/tool_commands.cc
|
||||
cli/flags.cc
|
||||
cli/tui/asar_patch.cc cli/tui/palette_editor.cc
|
||||
cli/tui/command_palette.cc
|
||||
cli/tui/chat_tui.cc
|
||||
cli/service/testing/test_suite_loader.cc
|
||||
@@ -158,7 +157,8 @@ if(YAZE_WITH_GRPC)
|
||||
|
||||
# Generate C++ code from .proto using the helper function from cmake/grpc.cmake
|
||||
target_add_protobuf(z3ed
|
||||
${CMAKE_SOURCE_DIR}/src/app/core/proto/imgui_test_harness.proto)
|
||||
${CMAKE_SOURCE_DIR}/src/protos/imgui_test_harness.proto
|
||||
${CMAKE_SOURCE_DIR}/src/protos/canvas_automation.proto)
|
||||
|
||||
# Add CLI gRPC service sources
|
||||
target_sources(z3ed PRIVATE
|
||||
|
||||
Reference in New Issue
Block a user