mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
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.
This commit is contained in:
parent
3db5d05519
commit
0ff13ccd67
4 changed files with 191 additions and 256 deletions
21
tools/editor/cli_dispatch.hpp
Normal file
21
tools/editor/cli_dispatch.hpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#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
|
||||
Loading…
Add table
Add a link
Reference in a new issue