Kelsidavis-WoWee/tools/editor/cli_magic_fix.hpp
Kelsi 74be3f6135 feat(editor): add --magic-fix to auto-rename files to canonical extension
Natural follow-up to --audit-tree: when that utility flags
ext-mismatch or magic-no-ext issues, --magic-fix proposes (and
optionally applies) the renames that resolve them. Walks a
directory recursively, reads each file's 4-byte magic, looks it
up in the format table, and renames to the canonical extension
when the current extension doesn't match (or is absent).

Defaults to dry-run for safety — prints the proposed renames so
they can be reviewed first; pass --apply to commit them. Refuses
to clobber existing files: when the target path already exists
(e.g. foo.wsct + foo.wsrg both with WSRG magic), the rename is
flagged as a collision and skipped, leaving both files in place
for manual resolution. Returns exit 1 if any proposals exist (in
dry-run) or any collisions are skipped (in apply), so it composes
into shell pipelines.

JSON sidecar via --json. Suggested workflow:
  --audit-tree dir          # find what's broken
  --magic-fix dir           # preview the auto-fixes
  --magic-fix dir --apply   # commit them
  --audit-tree dir          # confirm clean

CLI flag count 921 -> 922.
2026-05-09 21:57:26 -07:00

11 lines
195 B
C++

#pragma once
namespace wowee {
namespace editor {
namespace cli {
bool handleMagicFix(int& i, int argc, char** argv, int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee