Enhance CLI command structure and add new functionalities
- Refactored existing CLI commands to follow a more structured naming convention, improving clarity and usability. - Introduced new commands for dungeon and graphics handling, including `dungeon export`, `gfx export-sheet`, and `gfx import-sheet`, with placeholder implementations. - Added palette export and import commands, enhancing the CLI's capabilities for managing graphical assets. - Updated usage examples and help text to reflect the new command structure and improve user guidance. - Incremented version number in TUI components to reflect the latest changes.
This commit is contained in:
@@ -58,64 +58,109 @@ class ModernCLI {
|
||||
}
|
||||
|
||||
void SetupCommands() {
|
||||
commands_["asar"] = {
|
||||
.name = "asar",
|
||||
commands_["patch apply-asar"] = {
|
||||
.name = "patch apply-asar",
|
||||
.description = "Apply Asar 65816 assembly patch to ROM",
|
||||
.usage = "z3ed asar <patch.asm> [--rom=<rom_file>] [--output=<output_file>]",
|
||||
.usage = "z3ed patch apply-asar <patch.asm> [--rom=<rom_file>] [--output=<output_file>]",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleAsarCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["patch"] = {
|
||||
.name = "patch",
|
||||
commands_["patch apply-bps"] = {
|
||||
.name = "patch apply-bps",
|
||||
.description = "Apply BPS patch to ROM",
|
||||
.usage = "z3ed patch <patch.bps> [--rom=<rom_file>] [--output=<output_file>]",
|
||||
.usage = "z3ed patch apply-bps <patch.bps> [--rom=<rom_file>] [--output=<output_file>]",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandlePatchCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["extract"] = {
|
||||
.name = "extract",
|
||||
commands_["patch extract-symbols"] = {
|
||||
.name = "patch extract-symbols",
|
||||
.description = "Extract symbols from assembly file",
|
||||
.usage = "z3ed extract <patch.asm>",
|
||||
.usage = "z3ed patch extract-symbols <patch.asm>",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleExtractCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["validate"] = {
|
||||
.name = "validate",
|
||||
commands_["patch validate"] = {
|
||||
.name = "patch validate",
|
||||
.description = "Validate assembly file syntax",
|
||||
.usage = "z3ed validate <patch.asm>",
|
||||
.usage = "z3ed patch validate <patch.asm>",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleValidateCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["info"] = {
|
||||
.name = "info",
|
||||
commands_["rom info"] = {
|
||||
.name = "rom info",
|
||||
.description = "Show ROM information",
|
||||
.usage = "z3ed info [--rom=<rom_file>]",
|
||||
.usage = "z3ed rom info [--rom=<rom_file>]",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleInfoCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["convert"] = {
|
||||
.name = "convert",
|
||||
commands_["dungeon export"] = {
|
||||
.name = "dungeon export",
|
||||
.description = "Export dungeon data to a file",
|
||||
.usage = "z3ed dungeon export <room_id> --format <format>",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleDungeonExportCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["gfx export-sheet"] = {
|
||||
.name = "gfx export-sheet",
|
||||
.description = "Export a graphics sheet to a file",
|
||||
.usage = "z3ed gfx export-sheet <sheet_id> --to <file>",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleGfxExportCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["gfx import-sheet"] = {
|
||||
.name = "gfx import-sheet",
|
||||
.description = "Import a graphics sheet from a file",
|
||||
.usage = "z3ed gfx import-sheet <sheet_id> --from <file>",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleGfxImportCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["palette export"] = {
|
||||
.name = "palette export",
|
||||
.description = "Export a palette to a file",
|
||||
.usage = "z3ed palette export --group <group> --id <id> --format <format>",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandlePaletteExportCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["palette import"] = {
|
||||
.name = "palette import",
|
||||
.description = "Import a palette from a file",
|
||||
.usage = "z3ed palette import --group <group> --id <id> --from <file>",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandlePaletteImportCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["util convert"] = {
|
||||
.name = "util convert",
|
||||
.description = "Convert between SNES and PC addresses",
|
||||
.usage = "z3ed convert <address> [--to-pc|--to-snes]",
|
||||
.usage = "z3ed util convert <address> [--to-pc|--to-snes]",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleConvertCommand(args);
|
||||
}
|
||||
};
|
||||
|
||||
commands_["test"] = {
|
||||
.name = "test",
|
||||
commands_["test run-assets"] = {
|
||||
.name = "test run-assets",
|
||||
.description = "Run comprehensive asset loading tests on ROM",
|
||||
.usage = "z3ed test [--rom=<rom_file>] [--graphics] [--overworld] [--dungeons]",
|
||||
.usage = "z3ed test run-assets [--rom=<rom_file>]",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleTestCommand(args);
|
||||
}
|
||||
@@ -130,10 +175,10 @@ class ModernCLI {
|
||||
}
|
||||
};
|
||||
|
||||
commands_["test-gui"] = {
|
||||
.name = "test-gui",
|
||||
commands_["test run-gui"] = {
|
||||
.name = "test run-gui",
|
||||
.description = "Run automated GUI tests",
|
||||
.usage = "z3ed test-gui --rom=<rom_file> --test=<test_name>",
|
||||
.usage = "z3ed test run-gui --rom=<rom_file> --test=<test_name>",
|
||||
.handler = [this](const std::vector<std::string>& args) -> absl::Status {
|
||||
return HandleTestGuiCommand(args);
|
||||
}
|
||||
@@ -157,7 +202,7 @@ class ModernCLI {
|
||||
std::cout << "z3ed - Yet Another Zelda3 Editor CLI Tool" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "USAGE:" << std::endl;
|
||||
std::cout << " z3ed [--tui] [command] [arguments]" << std::endl;
|
||||
std::cout << " z3ed [--tui] <resource> <action> [arguments]" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "GLOBAL FLAGS:" << std::endl;
|
||||
std::cout << " --tui Launch Text User Interface" << std::endl;
|
||||
@@ -171,21 +216,19 @@ class ModernCLI {
|
||||
std::cout << "COMMANDS:" << std::endl;
|
||||
|
||||
for (const auto& [name, info] : commands_) {
|
||||
std::cout << absl::StrFormat(" %-12s %s", name, info.description) << std::endl;
|
||||
std::cout << absl::StrFormat(" %-25s %s", name, info.description) << std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "EXAMPLES:" << std::endl;
|
||||
std::cout << " z3ed --tui # Launch TUI" << std::endl;
|
||||
std::cout << " z3ed asar patch.asm --rom=zelda3.sfc # Apply Asar patch" << std::endl;
|
||||
std::cout << " z3ed patch changes.bps --rom=zelda3.sfc # Apply BPS patch" << std::endl;
|
||||
std::cout << " z3ed extract patch.asm # Extract symbols" << std::endl;
|
||||
std::cout << " z3ed validate patch.asm # Validate assembly" << std::endl;
|
||||
std::cout << " z3ed info --rom=zelda3.sfc # Show ROM info" << std::endl;
|
||||
std::cout << " z3ed convert 0x008000 --to-pc # Convert address" << std::endl;
|
||||
std::cout << " z3ed patch apply-asar patch.asm --rom=zelda3.sfc # Apply Asar patch" << std::endl;
|
||||
std::cout << " z3ed patch apply-bps changes.bps --rom=zelda3.sfc # Apply BPS patch" << std::endl;
|
||||
std::cout << " z3ed patch extract-symbols patch.asm # Extract symbols" << std::endl;
|
||||
std::cout << " z3ed rom info --rom=zelda3.sfc # Show ROM info" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "For more information on a specific command:" << std::endl;
|
||||
std::cout << " z3ed help <command>" << std::endl;
|
||||
std::cout << " z3ed help <resource> <action>" << std::endl;
|
||||
}
|
||||
|
||||
absl::Status RunCommand(const std::string& command, const std::vector<std::string>& args) {
|
||||
@@ -197,9 +240,38 @@ class ModernCLI {
|
||||
return it->second.handler(args);
|
||||
}
|
||||
|
||||
#include "cli/handlers/dungeon.h"
|
||||
|
||||
private:
|
||||
std::map<std::string, CommandInfo> commands_;
|
||||
|
||||
absl::Status HandleDungeonExportCommand(const std::vector<std::string>& args) {
|
||||
DungeonExport handler;
|
||||
return handler.Run(args);
|
||||
}
|
||||
|
||||
absl::Status HandleGfxExportCommand(const std::vector<std::string>& args) {
|
||||
GfxExport handler;
|
||||
return handler.Run(args);
|
||||
}
|
||||
|
||||
absl::Status HandleGfxImportCommand(const std::vector<std::string>& args) {
|
||||
GfxImport handler;
|
||||
return handler.Run(args);
|
||||
}
|
||||
|
||||
absl::Status HandlePaletteExportCommand(const std::vector<std::string>& args) {
|
||||
PaletteExport handler;
|
||||
return handler.Run(args);
|
||||
}
|
||||
|
||||
absl::Status HandlePaletteImportCommand(const std::vector<std::string>& args) {
|
||||
PaletteImport handler;
|
||||
return handler.Run(args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
absl::Status HandleAsarCommand(const std::vector<std::string>& args) {
|
||||
if (args.empty()) {
|
||||
return absl::InvalidArgumentError("Asar command requires a patch file");
|
||||
@@ -516,7 +588,7 @@ class ModernCLI {
|
||||
}
|
||||
|
||||
absl::Status HandleHelpCommand(const std::vector<std::string>& args) {
|
||||
std::string command = args.empty() ? "" : args[0];
|
||||
std::string command = args.empty() ? "" : absl::StrJoin(args, " ");
|
||||
ShowHelp(command);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -555,8 +627,16 @@ int main(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string command = args[1];
|
||||
std::vector<std::string> command_args(args.begin() + 2, args.end());
|
||||
std::string command;
|
||||
std::vector<std::string> command_args;
|
||||
|
||||
if (args.size() >= 3) {
|
||||
command = std::string(args[1]) + " " + std::string(args[2]);
|
||||
command_args.assign(args.begin() + 3, args.end());
|
||||
} else {
|
||||
command = args[1];
|
||||
command_args.assign(args.begin() + 2, args.end());
|
||||
}
|
||||
|
||||
auto status = cli.RunCommand(command, command_args);
|
||||
if (!status.ok()) {
|
||||
|
||||
21
src/cli/handlers/dungeon.cc
Normal file
21
src/cli/handlers/dungeon.cc
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "cli/z3ed.h"
|
||||
#include "app/zelda3/dungeon/dungeon_editor_system.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace cli {
|
||||
|
||||
absl::Status DungeonExport::Run(const std::vector<std::string>& arg_vec) {
|
||||
if (arg_vec.size() < 1) {
|
||||
return absl::InvalidArgumentError("Usage: dungeon export <room_id>");
|
||||
}
|
||||
|
||||
int room_id = std::stoi(arg_vec[0]);
|
||||
|
||||
// TODO: Implement dungeon export logic
|
||||
std::cout << "Dungeon export for room " << room_id << " not yet implemented." << std::endl;
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace yaze
|
||||
29
src/cli/handlers/gfx.cc
Normal file
29
src/cli/handlers/gfx.cc
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "cli/z3ed.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace cli {
|
||||
|
||||
absl::Status GfxExport::Run(const std::vector<std::string>& arg_vec) {
|
||||
if (arg_vec.size() < 2) {
|
||||
return absl::InvalidArgumentError("Usage: gfx export-sheet <sheet_id> --to <file>");
|
||||
}
|
||||
|
||||
// TODO: Implement gfx export logic
|
||||
std::cout << "Gfx export not yet implemented." << std::endl;
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GfxImport::Run(const std::vector<std::string>& arg_vec) {
|
||||
if (arg_vec.size() < 2) {
|
||||
return absl::InvalidArgumentError("Usage: gfx import-sheet <sheet_id> --from <file>");
|
||||
}
|
||||
|
||||
// TODO: Implement gfx import logic
|
||||
std::cout << "Gfx import not yet implemented." << std::endl;
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace yaze
|
||||
29
src/cli/handlers/palette.cc
Normal file
29
src/cli/handlers/palette.cc
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "cli/z3ed.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace cli {
|
||||
|
||||
absl::Status PaletteExport::Run(const std::vector<std::string>& arg_vec) {
|
||||
if (arg_vec.size() < 2) {
|
||||
return absl::InvalidArgumentError("Usage: palette export --group <group> --id <id> --format <format>");
|
||||
}
|
||||
|
||||
// TODO: Implement palette export logic
|
||||
std::cout << "Palette export not yet implemented." << std::endl;
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status PaletteImport::Run(const std::vector<std::string>& arg_vec) {
|
||||
if (arg_vec.size() < 2) {
|
||||
return absl::InvalidArgumentError("Usage: palette import --group <group> --id <id> --from <file>");
|
||||
}
|
||||
|
||||
// TODO: Implement palette import logic
|
||||
std::cout << "Palette import not yet implemented." << std::endl;
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace yaze
|
||||
@@ -22,9 +22,6 @@ void SwitchComponents(ftxui::ScreenInteractive &screen, LayoutID layout) {
|
||||
screen.ExitLoopClosure()();
|
||||
screen.Clear();
|
||||
app_context.current_layout = layout;
|
||||
|
||||
// Clear the buffer
|
||||
// std::cout << "\033[2J\033[1;1H";
|
||||
}
|
||||
|
||||
bool HandleInput(ftxui::ScreenInteractive &screen, ftxui::Event &event,
|
||||
@@ -704,7 +701,7 @@ void PaletteEditorComponent(ftxui::ScreenInteractive &screen) {
|
||||
|
||||
void HelpComponent(ftxui::ScreenInteractive &screen) {
|
||||
auto help_text = vbox({
|
||||
text("z3ed v0.3.1") | bold | color(Color::Yellow),
|
||||
text("z3ed v0.3.2") | bold | color(Color::Yellow),
|
||||
text("by scawful") | color(Color::Magenta),
|
||||
text("The Legend of Zelda: A Link to the Past Hacking Tool") |
|
||||
color(Color::Red),
|
||||
@@ -866,7 +863,7 @@ void MainMenuComponent(ftxui::ScreenInteractive &screen) {
|
||||
auto title = border(hbox({
|
||||
text("z3ed") | bold | color(Color::Blue1),
|
||||
separator(),
|
||||
text("v0.3.1") | bold | color(Color::Green1),
|
||||
text("v0.3.2") | bold | color(Color::Green1),
|
||||
separator(),
|
||||
text(rom_information) | bold | color(Color::Red1),
|
||||
}));
|
||||
|
||||
@@ -39,7 +39,7 @@ enum class MainMenuEntry {
|
||||
kExit,
|
||||
};
|
||||
|
||||
enum LayoutID {
|
||||
enum class LayoutID {
|
||||
kLoadRom,
|
||||
kApplyAsarPatch,
|
||||
kApplyBpsPatch,
|
||||
|
||||
@@ -28,6 +28,9 @@ add_executable(
|
||||
cli/handlers/compress.cc
|
||||
cli/handlers/patch.cc
|
||||
cli/handlers/tile16_transfer.cc
|
||||
cli/handlers/dungeon.cc
|
||||
cli/handlers/gfx.cc
|
||||
cli/handlers/palette.cc
|
||||
app/rom.cc
|
||||
app/core/project.cc
|
||||
app/core/asar_wrapper.cc
|
||||
|
||||
@@ -46,6 +46,31 @@ class Tile16Transfer : public CommandHandler {
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class GfxExport : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class GfxImport : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class PaletteExport : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class PaletteImport : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class DungeonExport : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override;
|
||||
};
|
||||
|
||||
class Open : public CommandHandler {
|
||||
public:
|
||||
absl::Status Run(const std::vector<std::string>& arg_vec) override {
|
||||
@@ -186,4 +211,4 @@ class Expand : public CommandHandler {
|
||||
} // namespace cli
|
||||
} // namespace yaze
|
||||
|
||||
#endif
|
||||
#endif // YAZE_CLI_Z3ED_H
|
||||
|
||||
Reference in New Issue
Block a user