refactor(editor): table-driven multi-arg flag validation

Collapse main.cpp's hand-written ladder of 28 individual
"if --foo and i+N >= argc, print message, return 1" blocks
into a single loop over kMultiArgRequired (struct of flag,
needed count, synopsis).

main.cpp drops from 246 → 126 lines. Adding a new multi-arg
flag now means appending one row to cli_multi_arg_required.cpp
instead of pasting another six lines into the validation
ladder. Mirrors the kArgRequired pattern that handles
single-arg flags.
This commit is contained in:
Kelsi 2026-05-09 10:22:36 -07:00
parent a9f4e322d5
commit ff82c0ade2
4 changed files with 87 additions and 127 deletions

View file

@ -0,0 +1,30 @@
#pragma once
#include <cstddef>
namespace wowee {
namespace editor {
namespace cli {
// Companion to kArgRequired for flags that take MORE than one
// positional argument. main.cpp uses this list for the early
// "missing argument" detector — for each entry we check whether
// argv[i+needed] would run off the end and, if so, print the
// synopsis and exit 1 instead of silently dropping into the GUI.
//
// `needed` is the count of *positional* args after the flag.
// `synopsis` is the full message shown to the user; it should
// embed both the flag and the slot list (e.g. "<zoneDir> <x> <y>")
// so a single std::fprintf reads naturally.
struct MultiArgFlag {
const char* flag;
int needed;
const char* synopsis;
};
extern const MultiArgFlag kMultiArgRequired[];
extern const std::size_t kMultiArgRequiredSize;
} // namespace cli
} // namespace editor
} // namespace wowee