Declare mutually exclusive switches in CommandArgParser instead of an inline check per command #598

Open
opened 2026-09-21 18:50:07 +00:00 by claude · 4 comments
Member

Found while working IW-581.

Two commands refuse a pair of switches with an inline check of their own:

  • PhasePr refuses --batch with --no-wait.
  • Start refuses --no-agent with --prompt (added by IW-581).

Each check is written, tested and documented by hand: Start has its own refusal text, its own exit-code line in CommandHelp, and two harness tests that check both orders. The next command with such a pair repeats all of it.

PROPOSED FIX. Let CommandArgParser / CommandHelp declare a set of mutually exclusive switches. The parser refuses the pair before run does anything, with one standard message, and the help lists the exclusion. The inline checks in PhasePr and Start then go.

Related: #569 proposes to make the PhasePr pair unrepresentable with a sum type. That is a different fix for one of the two cases; a decision on #569 affects the scope of this issue.

Found while working IW-581. Two commands refuse a pair of switches with an inline check of their own: - `PhasePr` refuses `--batch` with `--no-wait`. - `Start` refuses `--no-agent` with `--prompt` (added by IW-581). Each check is written, tested and documented by hand: `Start` has its own refusal text, its own exit-code line in `CommandHelp`, and two harness tests that check both orders. The next command with such a pair repeats all of it. PROPOSED FIX. Let `CommandArgParser` / `CommandHelp` declare a set of mutually exclusive switches. The parser refuses the pair before `run` does anything, with one standard message, and the help lists the exclusion. The inline checks in `PhasePr` and `Start` then go. Related: #569 proposes to make the `PhasePr` pair unrepresentable with a sum type. That is a different fix for one of the two cases; a decision on #569 affects the scope of this issue.
Author
Member
  • An earlier flag-shaped occurrence of a last-wins valued flag is refused although a later occurrence is valid, and no test or doc states it — --timeout --wip --timeout 10m gives FlagShapedValue("--timeout", "--wip"); CommandArgParser.parse doc says only the last occurrence "is validated" (review-phase-02-20261015-150758.md, testing) (from IW-552)
- [ ] An earlier flag-shaped occurrence of a last-wins valued flag is refused although a later occurrence is valid, and no test or doc states it — `--timeout --wip --timeout 10m` gives `FlagShapedValue("--timeout", "--wip")`; `CommandArgParser.parse` doc says only the last occurrence "is validated" (review-phase-02-20261015-150758.md, testing) (from IW-552)
Author
Member

Intake: agent-ready
Workflow: waterfall
Reason: all gates passed
Analysis: project-management/issues/IW-598/analysis.md on branch IW-598

Intake: agent-ready Workflow: waterfall Reason: all gates passed Analysis: project-management/issues/IW-598/analysis.md on branch IW-598
Author
Member

Implement: needs-human
Reason: batch-implement exit 1 — the kanon plugin does not compile against the iw-cli core of this branch, so no phase ran

ForgeCatchUp.scala in the installed kanon plugin expects fetchPullRequestForBranch to return Either[String, _]. The iw-cli core on main returns Either[TrackerError, _] since #778. The failure is in the plugin, not in this issue: every iw-cli issue stops at the same place until the plugin is updated. batch-implement.log was not written. The command output:

[warn]  Using directives detected in multiple files:
- /home/mph/.local/share/iw/plugins/kanon/lib/deps.scala:1:1-7:41
It is recommended to keep them centralized in the /home/mph/Devel/iw/iw-cli-IW-598/core/project.scala file.

[error] /home/mph/.local/share/iw/plugins/kanon/lib/batch/ForgeCatchUp.scala:143:7
[error] Found:    Either[iw.core.model.TrackerError, Option[batch.ForgeState]]
[error] Required: Either[String, Option[batch.ForgeState]]
Compilation failed

After the plugin compiles against iw-cli main, put agent-ready back on this issue.

Implement: needs-human Reason: batch-implement exit 1 — the kanon plugin does not compile against the iw-cli core of this branch, so no phase ran `ForgeCatchUp.scala` in the installed kanon plugin expects `fetchPullRequestForBranch` to return `Either[String, _]`. The iw-cli core on `main` returns `Either[TrackerError, _]` since #778. The failure is in the plugin, not in this issue: every iw-cli issue stops at the same place until the plugin is updated. batch-implement.log was not written. The command output: ``` [warn] Using directives detected in multiple files: - /home/mph/.local/share/iw/plugins/kanon/lib/deps.scala:1:1-7:41 It is recommended to keep them centralized in the /home/mph/Devel/iw/iw-cli-IW-598/core/project.scala file. [error] /home/mph/.local/share/iw/plugins/kanon/lib/batch/ForgeCatchUp.scala:143:7 [error] Found: Either[iw.core.model.TrackerError, Option[batch.ForgeState]] [error] Required: Either[String, Option[batch.ForgeState]] Compilation failed ``` After the plugin compiles against iw-cli `main`, put `agent-ready` back on this issue.
Author
Member

Release: the implement loop failed this issue for a reason outside it. The kanon plugin did not compile against iw-cli main, because the tracker port now returns TrackerError (iw-cli #778). The plugin fix is dev-docs #484, and iw-cli 0.22.1 carries the core change. The issue goes back to the implement loop.

Release: the implement loop failed this issue for a reason outside it. The kanon plugin did not compile against iw-cli main, because the tracker port now returns TrackerError (iw-cli #778). The plugin fix is dev-docs #484, and iw-cli 0.22.1 carries the core change. The issue goes back to the implement loop.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
iterative-works/iw-cli#598
No description provided.