mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
refactor(editor): extract for-each batch runners into cli_for_each.cpp
Moves the two batch-runner handlers (--for-each-zone,
--for-each-tile) out of main.cpp into a new
cli_for_each.{hpp,cpp} module. Both substitute `{}` with the
iterated path (find -exec convention) and shell-escape every
token before passing to std::system. Exit code is the failure
count, capped at 255 so the shell can still see it.
main.cpp shrinks by 157 lines (2,964 to 2,807).
This commit is contained in:
parent
4932947631
commit
02564171b5
4 changed files with 228 additions and 161 deletions
22
tools/editor/cli_for_each.hpp
Normal file
22
tools/editor/cli_for_each.hpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
// Dispatch the batch-runner handlers — iterate over zones (or
|
||||
// tiles within a zone) and execute a shell command for each
|
||||
// one, with `{}` substitution like find -exec.
|
||||
// --for-each-zone <projectDir> -- <cmd>
|
||||
// --for-each-tile <zoneDir> -- <cmd>
|
||||
//
|
||||
// Useful for batch-validating, rebuilding, or processing every
|
||||
// zone / tile without hand-typing the loop. Exit code is the
|
||||
// failure count, capped at 255 so the shell can still see it.
|
||||
//
|
||||
// Returns true if matched; outRc holds the exit code.
|
||||
bool handleForEach(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