feat(editor): add --list-primitives focused introspection

Filtered subset of --list-commands: just procedural primitive
flags (--gen-mesh-* and --gen-texture-*). Walks the shared
kArgRequired registry so it auto-tracks new primitives as they
land — no parallel list to maintain. Useful when authoring
content packs to discover what's available without scrolling
through the full --help dump.

Flags:
  --mesh        — show only --gen-mesh-* (default: both)
  --texture     — show only --gen-texture-* (default: both)
  --json        — JSON output with meshCount/textureCount totals

Currently surfaces 70 procedural mesh primitives and 62
procedural texture primitives. JSON form is well-suited for
piping into sortable / searchable UIs (e.g. content-pack
authoring tools).
This commit is contained in:
Kelsi 2026-05-09 12:25:51 -07:00
parent 68db1be97a
commit ec76077b44
2 changed files with 59 additions and 0 deletions

View file

@ -371,12 +371,69 @@ int handleVersion(int& /*i*/, int /*argc*/, char** /*argv*/) {
return 0;
}
int handleListPrimitives(int& i, int argc, char** argv) {
// Focused subset of --list-commands: just the procedural
// primitives (--gen-mesh-* and --gen-texture-* flags). Useful
// when authoring content packs to discover what's available
// without scrolling through the full --help dump. Walks the
// shared kArgRequired registry so it auto-tracks new
// primitives as they're added — no parallel list.
bool jsonOut = false;
bool meshOnly = false;
bool textureOnly = false;
while (i + 1 < argc && argv[i + 1][0] == '-') {
if (std::strcmp(argv[i + 1], "--json") == 0) {
jsonOut = true; ++i;
} else if (std::strcmp(argv[i + 1], "--mesh") == 0) {
meshOnly = true; ++i;
} else if (std::strcmp(argv[i + 1], "--texture") == 0) {
textureOnly = true; ++i;
} else {
break;
}
}
std::vector<std::string> meshes;
std::vector<std::string> textures;
for (std::size_t k = 0; k < kArgRequiredSize; ++k) {
const char* flag = kArgRequired[k];
if (std::strncmp(flag, "--gen-mesh-", 11) == 0) {
meshes.emplace_back(flag);
} else if (std::strncmp(flag, "--gen-texture-", 14) == 0) {
textures.emplace_back(flag);
}
}
std::sort(meshes.begin(), meshes.end());
std::sort(textures.begin(), textures.end());
if (jsonOut) {
nlohmann::json j;
if (!textureOnly) j["meshes"] = meshes;
if (!meshOnly) j["textures"] = textures;
if (!textureOnly) j["meshCount"] = meshes.size();
if (!meshOnly) j["textureCount"] = textures.size();
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
if (!textureOnly) {
std::printf("Procedural meshes (%zu):\n", meshes.size());
for (const auto& m : meshes) std::printf(" %s\n", m.c_str());
}
if (!meshOnly) {
if (!textureOnly) std::printf("\n");
std::printf("Procedural textures (%zu):\n", textures.size());
for (const auto& t : textures) std::printf(" %s\n", t.c_str());
}
return 0;
}
} // namespace
bool handleIntrospect(int& i, int argc, char** argv, int& outRc) {
if (std::strcmp(argv[i], "--list-commands") == 0) {
outRc = handleListCommands(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--list-primitives") == 0) {
outRc = handleListPrimitives(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-cli-stats") == 0) {
outRc = handleInfoCliStats(i, argc, argv); return true;
}