3#include "absl/strings/numbers.h"
4#include "absl/strings/str_format.h"
13static const std::string kDefaultServerAddress =
"localhost:50051";
18 auto tile_id_str = parser.
GetString(
"tile").value();
19 auto x_str = parser.
GetString(
"x").value();
20 auto y_str = parser.
GetString(
"y").value();
23 if (!absl::SimpleHexAtoi(tile_id_str, &tile_id) ||
24 !absl::SimpleAtoi(x_str, &x) || !absl::SimpleAtoi(y_str, &y)) {
25 return absl::InvalidArgumentError(
"Invalid tile ID or coordinate format.");
31 return absl::UnavailableError(
"Failed to connect to GUI server: " + std::string(status.message()));
35 std::string canvas_id =
"overworld";
36 status = client.
SetTile(canvas_id, x, y, tile_id);
39 formatter.
AddField(
"tile_id", absl::StrFormat(
"0x%03X", tile_id));
43 formatter.
AddField(
"status",
"Success");
45 formatter.
AddField(
"status",
"Failed");
46 formatter.
AddField(
"error", std::string(status.message()));
56 auto target = parser.
GetString(
"target").value();
57 auto click_type_str = parser.
GetString(
"click-type").value_or(
"left");
66 return absl::UnavailableError(
"Failed to connect to GUI server: " + std::string(status.message()));
69 auto result = client.
Click(target, click_type);
72 formatter.
AddField(
"target", target);
73 formatter.
AddField(
"click_type", click_type_str);
76 formatter.
AddField(
"status", result->success ?
"Success" :
"Failed");
77 if (!result->success) {
78 formatter.
AddField(
"error", result->message);
80 formatter.
AddField(
"execution_time_ms",
static_cast<int>(result->execution_time.count()));
82 formatter.
AddField(
"status",
"Error");
83 formatter.
AddField(
"error", std::string(result.status().message()));
87 return result.status();
93 auto window = parser.
GetString(
"window").value_or(
"");
94 auto type_str = parser.
GetString(
"type").value_or(
"all");
99 return absl::UnavailableError(
"Failed to connect to GUI server: " + std::string(status.message()));
110 formatter.
AddField(
"window_filter", window);
113 formatter.
AddField(
"total_widgets", result->total_widgets);
114 formatter.
AddField(
"status",
"Success");
117 for (
const auto& win : result->windows) {
119 formatter.
AddField(
"name", win.name);
123 for (
const auto& widget : win.widgets) {
124 if (count++ > 50)
break;
125 formatter.
AddArrayItem(absl::StrFormat(
"%s (%s) - %s", widget.label, widget.type, widget.path));
132 formatter.
AddField(
"status",
"Error");
133 formatter.
AddField(
"error", std::string(result.status().message()));
137 return result.status();
143 auto region = parser.
GetString(
"region").value_or(
"full");
144 auto image_format = parser.
GetString(
"format").value_or(
"PNG");
147 auto status = client.
Connect();
149 return absl::UnavailableError(
"Failed to connect to GUI server: " + std::string(status.message()));
152 auto result = client.
Screenshot(region, image_format);
155 formatter.
AddField(
"region", region);
156 formatter.
AddField(
"image_format", image_format);
159 formatter.
AddField(
"status", result->success ?
"Success" :
"Failed");
160 if (result->success) {
161 formatter.
AddField(
"output_path", result->message);
163 formatter.
AddField(
"error", result->message);
166 formatter.
AddField(
"status",
"Error");
167 formatter.
AddField(
"error", std::string(result.status().message()));
171 return result.status();
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
absl::Status SetTile(const std::string &canvas_id, int x, int y, int tile_id)
Client for automating YAZE GUI through gRPC.
absl::StatusOr< AutomationResult > Screenshot(const std::string ®ion="full", const std::string &format="PNG")
Capture a screenshot.
absl::Status Connect()
Connect to the test harness server.
absl::StatusOr< DiscoverWidgetsResult > DiscoverWidgets(const DiscoverWidgetsQuery &query)
absl::StatusOr< AutomationResult > Click(const std::string &target, ClickType type=ClickType::kLeft)
Click a GUI element.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
Utility for parsing common CLI argument patterns.
std::optional< std::string > GetString(const std::string &name) const
Parse a named argument (e.g., –format=json or –format json)
ClickType
Type of click action to perform.