Kelsidavis-WoWee/tools/editor/cli_dispatch.hpp
Kelsi 0ff13ccd67 refactor(editor): replace 60-handler chain with table-driven dispatch
Adds cli_dispatch.{hpp,cpp} containing a static table of every
extracted handler family's dispatch function. The table-walker
tryDispatchAll() iterates the table once per argv token, calling
each handler in turn. handleConvertSingle stays as a special-
case call in main.cpp because it threads dataPath through.

main.cpp shrinks from 486 to 236 lines (-250). Adding a new
handler module now requires touching only cli_dispatch.cpp's
include list + table — no main.cpp edits, no growing
if-else chain. The 60+ #include lines for individual cli_*
modules collapse to one #include for cli_dispatch.hpp.
2026-05-09 10:15:51 -07:00

21 lines
742 B
C++

#pragma once
namespace wowee {
namespace editor {
namespace cli {
// Try every registered handler family in turn against argv[i].
// Returns true if a handler claimed the flag (sets outRc); the
// caller should return outRc immediately. Returns false if no
// handler matched — the caller falls through to its own
// inline-handler chain (for handlers needing extra parameters
// like dataPath, or for the GUI-state args --data / --adt).
//
// The handler-family table lives in cli_dispatch.cpp; adding a
// new module means adding one #include + one row there, no
// touching of main.cpp's argv loop required.
bool tryDispatchAll(int& i, int argc, char** argv, int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee