Skip to content

Add force flags for non-interactive overwrite - #46

Closed
thompsonmj wants to merge 4 commits into
mainfrom
feat/force-flag
Closed

Add force flags for non-interactive overwrite#46
thompsonmj wants to merge 4 commits into
mainfrom
feat/force-flag

Conversation

@thompsonmj

Copy link
Copy Markdown
Collaborator

Closes #11

Implements option 3 from the issue discussion: refuse to overwrite an existing output file by default, in both the CLI and the library.

  • get_checksums gains force=False and raises sumbuddy.exceptions.OutputFileExistsError (a FileExistsError subclass) before any walking or hashing when the output file exists, leaving the file untouched.
  • The CLI replaces the interactive overwrite prompt with -f/--force and a clear error message (exit code 1), so runs are never interactive.
  • New tests pin the contracts: refusal happens before gather_file_paths is called, the existing file is preserved, force=True regenerates output matching the default.csv fixture, the CLI exits without prompting, and both flag spellings overwrite end to end.
  • README updated: usage synopsis, options block, overwrite example, and Python usage section.

Breaking change: library callers writing to an existing output file previously overwrote silently and now get OutputFileExistsError unless they pass force=True. Slated for 2.0.0, with the version bump deferred to a release-prep PR per repo convention. After release, cautious-robot needs force=True at its get_checksums call site and a sum-buddy>=2.0.0 pin; until then its broad except would silently skip checksumming when a checksum CSV already exists.

Verification: pytest -rs gives 87 passed, 5 skipped (pre-existing algorithm-availability skips); ruff check . findings are identical to main (pre-existing only); manual CLI checks confirm first write succeeds, rerun refuses with no prompt, and --force overwrites.

thompsonmj and others added 4 commits July 27, 2026 13:54
Refuse to overwrite an existing output file by default in both the
library and the CLI, per the consensus on #11 (option 3):

- get_checksums gains force=False and raises OutputFileExistsError
  (subclass of FileExistsError) before any walking or hashing when the
  output file exists
- CLI replaces the interactive overwrite prompt with -f/--force and a
  clear error message, making all runs non-interactive

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@thompsonmj thompsonmj closed this Jul 27, 2026
@thompsonmj

Copy link
Copy Markdown
Collaborator Author

Again, closed because this was opened automatically by Claude in testing Fable 5. I'm thinking some explicit instructions are needed in an AGENTS.md file ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add flags for non-interactive use

1 participant