feat: implement barzel init --force to overwrite existing .barzel.toml#49
Merged
thefourcraft merged 3 commits intoproductionfrom May 4, 2026
Merged
feat: implement barzel init --force to overwrite existing .barzel.toml#49thefourcraft merged 3 commits intoproductionfrom
thefourcraft merged 3 commits intoproductionfrom
Conversation
- Add --force flag to 'barzel init' CLI command
- Add force: bool field to StdioRequest for {"command":"init"}
- run_init now returns InitOutcome (Created/Skipped/Overwritten)
- Existing config is skipped by default; overwritten only when force=true
- stdio init response includes config_status field with the outcome
- README updated with --force example and stdio force field
- init response message is now outcome-conditional: created -> 'project initialized' skipped -> 'config already exists' overwritten -> 'config overwritten' - README documents config_status table so agents know the three values - Test verifies message/status mapping is stable
…on code Test now calls the same init_status_and_message() used by handle_stdio instead of duplicating the match, so it guards the actual stdio contract.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the broken promise in
init.rs: the skip message said "use --force to overwrite" but--forcedidn't exist. Now it does.Changes
src/cli.rs— adds--forceflag to theInitsubcommand.src/init.rs—run_initsignature changes from(target, stdio) -> Result<()>to(target, stdio, force) -> Result<InitOutcome>.InitOutcomeisCreated | Skipped | Overwritten. Config is only overwritten whenforce=true.src/main.rs— threadsforcefrom parsed CLI args.src/stdio.rs— addsforce: bool(defaultfalse) toStdioRequest; threads it torun_init; addsconfig_status: "created" | "skipped" | "overwritten"to the init success response so agents can tell whether the config was actually written.README.md— documentsbarzel init . --force, the stdioforcefield, and adds theforcerow to the request fields table.Tests added (5)
init_skips_if_toml_already_exists_without_force— outcome isSkipped, sentinel preservedinit_force_overwrites_existing_toml— outcome isOverwritten, sentinel gonestdio_request_parses_force_true— JSON deserializationstdio_request_force_defaults_to_false— default when field absentinit_force_returns_overwritten_outcome— end-to-end outcome via stdio pathTest plan
cargo clippy --bin barzel -- -D warnings— cleancargo test --bins— 717 passed, 0 failed (was 712)git diff --stat— 5 files:src/cli.rs,src/init.rs,src/main.rs,src/stdio.rs,README.md