fix: model session destroy target as a required arg group - #1043
Conversation
`min session destroy -f` demanded both --all and <SESSION> on the error path, an impossible combination since --all and [SESSION] are mutually exclusive. Bare `min session destroy` likewise hid --all and rendered [SESSION] as required, contradicting the optional form shown by --help. Express the choice as a clap ArgGroup over `session` and `all` (required, non-multiple). This subsumes the old required_unless_present / conflicts_with pair on `session` and makes the error-path usage line render the two as alternatives. `force` still requires `--all` specifically, since it is a no-op for a single-session destroy. Closes: #1038
📝 WalkthroughWalkthroughThe ChangesSession destroy CLI
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/minimal/src/lib.rs (1)
2789-2812: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAlso assert that
SESSION --forceis rejected.The implementation correctly enforces this through
requires = "all", but the regression test should cover the direct single-session case as well as bare-f.assert!(parse(&["min", "session", "destroy", "--all", "web"]).is_err()); + assert!(parse(&["min", "session", "destroy", "web", "--force"]).is_err());🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/minimal/src/lib.rs` around lines 2789 - 2812, Extend destroy_models_session_and_all_as_required_alternatives to assert that parsing ["min", "session", "destroy", "web", "--force"] fails, covering --force with a specific SESSION in addition to the existing bare -f case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/minimal/src/lib.rs`:
- Around line 2789-2812: Extend
destroy_models_session_and_all_as_required_alternatives to assert that parsing
["min", "session", "destroy", "web", "--force"] fails, covering --force with a
specific SESSION in addition to the existing bare -f case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cd6f4933-789c-448d-a47a-ad7e834ae4cd
📒 Files selected for processing (1)
crates/minimal/src/lib.rs
Fixes #1038
Routing-Key: inbox-route/I_kwDOSUhdos8AAAABKmghtQ
min session destroy -fdemanded both--alland<SESSION>on the error path — impossible, since--alland[SESSION]are mutually exclusive — while baremin session destroyhid--alland marked[SESSION]required, contradicting--help. The fix drops therequired_unless_present/conflicts_withpair onsessionfor a clapArgGroupoversessionandall(required, non-multiple), so the usage line renders them as alternatives.forcestill requires--allspecifically: it is read only in the--allbranch (destroy_all_sessions) and is a no-op for a single-session destroy, so tying it to--all— not the group, as the routing hint proposed — is the correct scope.Verification
cargo fmt --all --check --manifest-path target/Cargo.toml— clean, no diffcargo clippy --workspace --locked -- -D warnings— exit 0, no warningscargo build --workspace --locked— exit 0cargo test --workspace --locked— exit 0 (minimal lib: 132 passed, incl. new regression test)Note
Fix
session destroyto require exactly one of a session identifier or--allPreviously, the
DestroyArgsstruct used per-fieldrequired_unless_present/conflicts_withconstraints to enforce mutual exclusivity. This replaces those with a clapArgGroupnamedtargetthat marks the group as required and non-multiple, so supplying neither or both is a parse error. A new test in lib.rs covers the three cases: session-only,--all-only, and both together.Macroscope summarized f2daff3.
Summary by CodeRabbit
min session destroycommands.--all.--allwith a session identifier.--forceis used only with--all.