r/CLI • u/SuitEvening48 • 2d ago
What should a batch command do when 99 files succeed and one fails?
For a command that processes 100 files and fails on one, what output makes the next step obvious? Do you prefer a non-zero exit code with a separate list of failures, a summary on stderr, or something else? I'm especially interested in retrying just the failed items without parsing a wall of logs.
1
Upvotes
2
u/illegal_appendix 2d ago
Non-zero exit for sure. Then a short line at the end like 99 ok, 1 failed, with the failed file names on their own lines so I can feed them back in and rerun just those.
1
u/ysnows123 1d ago
There's good prior art to copy here, and people already know it:
--joblog jobs.logwrites one line per item with its exit status, and running again with--resume-failed(or--retry-failed) redoes only the failures. A lighter version of the same idea is a flag like--failed-to failed.txtthat writes just the failed paths, one per line, plus a-0option for NUL-separated output since filenames can contain newlines. Retrying is thenyourtool --from failed.txt.--json.