Repository navigation
fix(prompt): execute on Enter, validate required fields, show field help (issue #31) - #33
Merged
Merged
Conversation
Fixes the three defects in issue #31 that stop a wrapped command being driven to completion from the menu. Enter is positional (F1) — `PromptKeyAction::enter()` only submitted when the active field happened to be the last one, because Enter doubled as "next field". `dev:mode` declares `enable`, `disable`, `status` in that order, so Space on `disable` followed by Enter advanced to `status` and ran nothing. Enter now executes from any field; Tab/Down/Up remain the only navigation, and the active index already wraps so nothing becomes unreachable. Required input is not validated (F2) — a blank required argument was passed as `''`, which Symfony accepts as a supplied value, so the command ran and failed deep inside instead of the form naming what was missing. Submission is now refused while any required field is blank: the blank fields are named, focus moves to the first of them, and everything already entered is left intact. Help text disappears behind defaults (F3) — the description was handed to `TextInput::placeholder()`, which draws only when the field is empty, so it vanished exactly where it was needed: a declared default pre-fills the field. Flag fields showed no description at all, since `render()` returned before reaching the widget. The description now renders on the row between the last field and the key hints, which was already free, and a refusal report takes precedence there. Blank optional fields are still omitted so the command's own default applies. Required fields are marked with `*`, and requiredness is read from the command's own definition. Only an argument can carry it — `InputOption` has no required concept — so a command needing a mandatory value has to declare it as a required argument; `user:init-db` is being fixed accordingly in webware-usermanager. Also: - `PromptState::$refused` plus `missingIndexes()`; the report is computed from the current values so it shrinks as fields are filled in rather than going stale. - render()'s field-kind branch is a match expression over FieldKind instead of an if/continue, per the stated `match`-over-`if` convention. - infection.json5.dist ignores re-keyed to the shifted line numbers (render::83 -> 86, confirm::158/165/172 -> 196/203/210). No new ignores, and no mutator was disabled. - docs/v1/command-input.md documents the key contract, the marker and the requiredness rule. Gates: mago format/lint/analyze/guard clean; 131 unit + 2 integration tests; 100% line coverage (487/487); MSI 100%, 0 escaped.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The already-disabled and already-enabled branches returned before clearing the cache, so a cache outlived the toggle meant to end it. The aggregator serves an existing cache without consulting a single provider, so nothing else could correct it. Signed-off-by: Joey Smith <jsmith@webinertia.net>
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.
What
Fixes the three defects that stop a wrapped command being driven to completion from the menu. 10 files, +406/−53.
The three findings
PromptKeyAction::enter()only submitted when the active field was the last one, because Enter doubled as "next field".dev:modedeclaresenable,disable,statusin that order — Space ondisablethen Enter advanced tostatusand ran nothing. This is the reported failure.'', which Symfony accepts as a supplied value, so the command ran and failed deep inside instead of the form naming what was missing.TextInput::placeholder(), which draws only when the field is empty — so it vanished exactly where it was needed, since a declared default pre-fills the field. Flag fields showed no description at all, becauserender()returned before reaching the widget.F1 also affects
generate-template-map,servicemanager:generate-deps-for-config-factoryand every mezzio-tooling command with more than one field; F2 affects every command with a required argument.The asterisk, and what "required" means
Required fields are marked
*, read from the command's own definition. Only an argument can carry requiredness —InputOptionhas no required concept — so a command needing a mandatory value must declare it as a required argument.user:init-dbdeclares its four mandatory values as optional options and asks for them inexecute(), so the console cannot see them; that fix lands separately in webware-usermanager.Also in this PR
PromptState::$refused+missingIndexes(); the report is computed from the current values, so it shrinks as fields are filled in instead of showing a staleRequired: configFileafter that field is filled.render()'s field-kind branch is now amatchexpression overFieldKindrather than anif/continue, per the statedmatch-over-ifconvention.infection.json5.dist: ignores re-keyed to the shifted line numbers (render::83→86,confirm::158/165/172→196/203/210). No new ignores, no mutator disabled.docs/v1/command-input.mddocuments the key contract, the marker and the requiredness rule; linked from the README.Also fixed here —
dev:modeleft the config cache in place (issue #34)disableandenablereturned early when the requested state was already inforce, before reaching
clearConfigCache(), so a stale cache outlived the togglemeant to end it. That matters more than it looks:
ConfigAggregatorserves anexisting cache without consulting a single provider, so a cache disagreeing with
config/development.config.phpis authoritative and nothing else can correct it.The cache is now dropped on every enable and disable, including the
already-in-state branches.
execute()became a singlematchover the threeflags, and the dist copy moved into
copyDistFile(), which reports its ownfailure — that also brought the class back under the
kan-defectthreshold withno suppression.
Gates
mago fmt --checkmago lintmago analyzemago guardTwo notes on verification:
MenuCommand.phpand one escaped mutant. The escape was real — I had dropped theupkeystroke from the scripted loop test, leavingPromptKeyAction::Upunasserted; a dedicatedtestOnKeyUpMovesBack(3 fields at index 1, where++and--cannot both wrap to the same value) kills it. The timeouts did not reproduce on a re-run, andMenuCommand.phpalone scores 47/47 killed — they were cold-start contention, not a real gap.PromptKeyAction::enter()'s two-way guard stays anif/early-return. Amatchover a boolean obscures the intent rather than clarifying it; the convention is applied where there is a discrete set of cases.Docs
Artifacts for this work are in #32 (
FR-009–FR-012,SC-006/SC-007, Phase 8 tasksT029–T043).Closes #31
Closes #34