yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
rom_commands.h
Go to the documentation of this file.
1#ifndef YAZE_SRC_CLI_HANDLERS_ROM_COMMANDS_H_
2#define YAZE_SRC_CLI_HANDLERS_ROM_COMMANDS_H_
3
5
6namespace yaze {
7namespace cli {
8namespace handlers {
9
14 public:
15 std::string GetName() const override { return "rom-read"; }
16 std::string GetDescription() const {
17 return "Read raw bytes from ROM at an address";
18 }
19 std::string GetUsage() const override {
20 return "rom-read --address <hex> [--length <bytes>] "
21 "[--data-format <hex|ascii|both>] [--format <json|text>]";
22 }
23
24 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
25 return parser.RequireArgs({"address"});
26 }
27
28 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
29 resources::OutputFormatter& formatter) override;
30};
31
36 public:
37 std::string GetName() const override { return "rom-write"; }
38 std::string GetDescription() const {
39 return "Write raw bytes to ROM at an address";
40 }
41 std::string GetUsage() const override {
42 return "rom-write --address <hex> --data <hex_string>";
43 }
44
45 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
46 return parser.RequireArgs({"address", "data"});
47 }
48
49 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
50 resources::OutputFormatter& formatter) override;
51};
52
57 public:
58 std::string GetName() const override { return "rom-info"; }
59 std::string GetDescription() const { return "Display ROM information"; }
60 std::string GetUsage() const override { return "rom-info"; }
61
62 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
63 return absl::OkStatus();
64 }
65
66 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
67 resources::OutputFormatter& formatter) override;
68};
69
74 public:
75 std::string GetName() const override { return "rom-validate"; }
76 std::string GetDescription() const { return "Validate ROM file integrity"; }
77 std::string GetUsage() const override { return "rom-validate"; }
78
79 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
80 return absl::OkStatus();
81 }
82
83 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
84 resources::OutputFormatter& formatter) override;
85};
86
91 public:
92 std::string GetName() const override { return "rom-diff"; }
93 std::string GetDescription() const { return "Compare two ROM files"; }
94 std::string GetUsage() const override {
95 return "rom-diff --rom_a <file> --rom_b <file>";
96 }
97 bool RequiresRom() const override { return false; }
98
99 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
100 return parser.RequireArgs({"rom_a", "rom_b"});
101 }
102
103 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
104 resources::OutputFormatter& formatter) override;
105};
106
111 public:
112 std::string GetName() const override { return "rom-generate-golden"; }
113 std::string GetDescription() const {
114 return "Generate golden ROM file for testing";
115 }
116 std::string GetUsage() const override {
117 return "rom-generate-golden --rom_file <file> --golden_file <file>";
118 }
119 bool RequiresRom() const override { return false; }
120
121 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
122 return parser.RequireArgs({"rom_file", "golden_file"});
123 }
124
125 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
126 resources::OutputFormatter& formatter) override;
127};
128
133 public:
134 std::string GetName() const override { return "rom-resolve-address"; }
135 std::string GetDescription() const {
136 return "Resolve an address to a symbol name";
137 }
138 std::string GetUsage() const override {
139 return "rom-resolve-address --address <hex> [--max-offset <bytes>]";
140 }
141
142 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
143 return parser.RequireArgs({"address"});
144 }
145
146 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
147 resources::OutputFormatter& formatter) override;
148};
149
154 public:
155 std::string GetName() const override { return "rom-find-symbol"; }
156 std::string GetDescription() const { return "Find a symbol by name or pattern"; }
157 std::string GetUsage() const override {
158 return "rom-find-symbol --name <string>";
159 }
160
161 absl::Status ValidateArgs(const resources::ArgumentParser& parser) override {
162 return parser.RequireArgs({"name"});
163 }
164
165 absl::Status Execute(Rom* rom, const resources::ArgumentParser& parser,
166 resources::OutputFormatter& formatter) override;
167};
168
169} // namespace handlers
170} // namespace cli
171} // namespace yaze
172
173#endif // YAZE_SRC_CLI_HANDLERS_ROM_COMMANDS_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Command handler for comparing ROM files.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
bool RequiresRom() const override
Check if the command requires a loaded ROM.
std::string GetName() const override
Get the command name.
std::string GetUsage() const override
Get the command usage string.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
Command handler for finding a symbol by name.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string GetName() const override
Get the command name.
std::string GetUsage() const override
Get the command usage string.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
Command handler for generating golden ROM files.
bool RequiresRom() const override
Check if the command requires a loaded ROM.
std::string GetUsage() const override
Get the command usage string.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string GetName() const override
Get the command name.
Command handler for displaying ROM information.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string GetUsage() const override
Get the command usage string.
std::string GetName() const override
Get the command name.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
Command handler for reading raw ROM bytes.
std::string GetUsage() const override
Get the command usage string.
std::string GetName() const override
Get the command name.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
Command handler for resolving an address to a symbol.
std::string GetName() const override
Get the command name.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string GetUsage() const override
Get the command usage string.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
Command handler for validating ROM files.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
std::string GetUsage() const override
Get the command usage string.
std::string GetName() const override
Get the command name.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
Command handler for writing raw ROM bytes.
std::string GetUsage() const override
Get the command usage string.
std::string GetName() const override
Get the command name.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
Utility for parsing common CLI argument patterns.
absl::Status RequireArgs(const std::vector< std::string > &required) const
Validate that required arguments are present.
Base class for CLI command handlers.
Utility for consistent output formatting across commands.