feat: add dry-run mode for hook execution (#2116) (#2188)

- Global --dry-run flag and ECC_DRY_RUN=1 env var
- Enriched preview: shows target file path, tool name, and command
- --dry-run stripped from argv so command routing works correctly
- Handles non-JSON and empty stdin gracefully (session/stop hooks)
- 10 tests covering isDryRun(), hook gating, enriched output, CLI routing
This commit is contained in:
Naomi
2026-06-15 19:01:21 +01:00
committed by GitHub
parent d24c7185fc
commit 48608863ea
4 changed files with 326 additions and 2 deletions
+19 -1
View File
@@ -106,6 +106,7 @@ ECC selective-install CLI
Usage:
ecc <command> [args...]
ecc [install args...]
ecc --dry-run <command> [args...]
Commands:
${PRIMARY_COMMANDS.map(command => ` ${command.padEnd(15)} ${COMMANDS[command].description}`).join('\n')}
@@ -115,6 +116,9 @@ Compatibility:
ecc [args...] Without a command, args are routed to "install"
ecc help <command> Show help for a specific command
Global Flags:
--dry-run Preview actions without executing (sets ECC_DRY_RUN=1)
Examples:
ecc typescript
ecc install --profile developer --target claude
@@ -152,7 +156,21 @@ function resolveCommand(argv) {
return { mode: 'help' };
}
const [firstArg, ...restArgs] = args;
if (args.includes('--dry-run')) {
process.env.ECC_DRY_RUN = '1';
}
let cmdStart = 0;
while (cmdStart < args.length && args[cmdStart] === '--dry-run') {
cmdStart++;
}
if (cmdStart >= args.length) {
return { mode: 'help' };
}
const firstArg = args[cmdStart];
const restArgs = args.slice(cmdStart + 1);
if (firstArg === '--help' || firstArg === '-h') {
return { mode: 'help' };