Repository navigation
feat(interactivity)!: let a command word its prompts and skip the missing-argument warning - #148
Open
jpage-godaddy wants to merge 2 commits into
Open
jpage-godaddy wants to merge 2 commits into
jpage-godaddy wants to merge 2 commits into
Conversation
…sing-argument warning A command marked DefaultOnTty is meant to ask, so it now goes straight to its first question instead of printing a "missing required argument(s)" warning first. A command can also set the question for any arg it prompts for with CommandSpec::with_arg_prompt, instead of reusing the arg's --help sentence, which describes the flag and reads oddly as a question. - Add CommandSpec::with_arg_prompt. It applies to required args asked after a missing-argument error and to optional args named in with_prompted_args. --help and schema output are unchanged. Registration debug-asserts that the id names one of the command's args. - Add Prompter::notice, a default method, so the warning goes through the prompter and a test prompter can record it (ScriptedPrompter::notices). - Collapse the recovery and optional-prompt wrapper chains into one function each and narrow them, and the types they use, to pub(crate). Nothing outside the engine called them. - Add a note to AGENTS.md to keep the public surface small. BREAKING CHANGE: cli_engine::prompt no longer exports try_recover_missing_args, try_recover_missing_args_with, prompt_optional_args, RecoveryResult or OptionalPromptResult. The engine calls them itself while running a command, so a consumer does not need them. No consumer we know of imports any of them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
jpage-godaddy
requested review from
axburgess-godaddy,
mguerrero3-godaddy,
qcai-godaddy,
rts1-godaddy and
runruh-godaddy
as code owners
November 25, 2026 23:39
There was a problem hiding this comment.
🟡 Changes recommended
Clustered short flags can cause interactive recovery to ignore custom prompt settings, and the guide directs consumers to an inaccessible internal API.
2 open issues
What changed in this PR
This follow-up to #140 refines cli-engine’s guided prompting so commands can ask clearer questions without an unnecessary missing-argument warning.
Changes:
- Adds per-argument prompt wording while preserving help and schema output.
- Skips warnings for guided commands and makes notices capturable through
Prompter. - Makes recovery helpers crate-private, with corresponding documentation and test updates.
| File | Description |
|---|---|
| cli-engine/tests/interactivity.rs | Tests prompt wording, warnings, help stability, and registration validation. |
| cli-engine/src/prompt/tests.rs | Adapts recovery tests to internal prompt options. |
| cli-engine/src/prompt/scripted.rs | Records notices separately from questions. |
| cli-engine/src/prompt/recovery.rs | Applies custom wording and suppresses guided-command warnings. |
| cli-engine/src/prompt/prompter.rs | Adds the default notice method. |
| cli-engine/src/prompt/options.rs | Collects per-command prompting settings. |
| cli-engine/src/prompt/optional.rs | Applies custom wording to optional prompts. |
| cli-engine/src/prompt/mod.rs | Restricts recovery exports to crate scope. |
| cli-engine/src/command/spec.rs | Adds argument prompt storage and builder. |
| cli-engine/src/cli/schema_tree.rs | Validates prompt argument IDs during registration. |
| cli-engine/src/cli/run.rs | Passes command settings into prompting flows. |
| cli-engine/src/cli/lookup.rs | Looks up prompting settings by command path. |
| cli-engine/docs/concepts.md | Documents prompt customization and notice behavior. |
| AGENTS.md | Adds guidance on minimizing public APIs. |
Review effort: Balanced
…lk as recovery The settings lookup used a cruder reading of argv than recovery itself, so a clustered short flag before the command (for example -vv) could hide the command from it and a guided command would lose its framing and custom wording. Look the command up with the argument-aware walk that recovery already uses, and drop the duplicate walker. Also drop the docs sentence that pointed consumers at PromptOptions, which is crate-private. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
DefaultOnTtyis meant to ask, so it now goes straight to its first question. Before, it printed⚠ missing required argument(s): --provider-id, ...first, which reads like a mistake and madegddy domain-connect template initlook broken. An ordinary command keeps the warning, since it was probably typed incompletely.CommandSpec::with_arg_prompt("provider-id", "Provider ID (your domain name)")sets the question for one arg. By default a question is the arg's--helpsentence, which describes the flag and reads oddly as a question. The override applies to required args asked after a missing-argument error and to optional args named inwith_prompted_args(which still get(optional)).--helpand schema output don't change. Registration debug-asserts that the id names one of the command's args.Prompter::notice(a default method) carries the warning, so a prompter can capture or restyle it andScriptedPrompter::notices()returns it in a test, apart from the questions intranscript().pub, but nothing outside the engine calls them:rundoes. I collapsed their wrapper chains into one function each and made them, and the types they use,pub(crate). This follows the new note inAGENTS.md.Follow-up to #140. It came from trying
gddy domain-connect template initby hand on godaddy/cli#404.Breaking change
Removed from
cli_engine::prompt:try_recover_missing_args,try_recover_missing_args_with,prompt_optional_args,RecoveryResultandOptionalPromptResult. The first was public since 0.10.6 and the rest since 0.10.7. The engine calls all of them itself while running a command, and they have no use outside it. I searched thegodaddyorg (godaddy/cli and godaddy/cli-engine are the only repos that mentioncli_engine::prompt), and the local gdx checkouts and cli-domain-connect use none of them. What consumers import fromcli_engine::promptisAnswer,ScriptedPrompter,Prompter,TextValidator,prompt_repeatandprompt_confirm, and all of those stay. I can only vouch for repos I can see, so a private consumer would show up as a build break on upgrade. The PR is marked!and carries aBREAKING CHANGE:footer, per CONTRIBUTING.md.The wider cleanup of unneeded exports is tracked in DEVEX-1475.
Test plan
cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningsRUSTDOCFLAGS='-D warnings' cargo doc --no-depscargo test --workspace(970 pass)tests/interactivity.rs: a guided command shows no notice and starts with its first question; an ordinary command keeps the warning; custom wording (trailing dot dropped,(optional)appended); the--helpfallback;--helpoutput unchanged by a custom prompt; and the registration assert. A unit test checks that a command's prompt settings are found past clustered short flags, option values and aliases, using the same argument-aware walk recovery uses. (refined during review)Not covered by automated tests
The scripted prompter replaces the terminal, so how the prompts render on a real terminal isn't tested here. I haven't run this against a real terminal yet. The old behavior was checked on a pty during #140.
Manual verification
Setup: in the godaddy/cli repo, override the engine:
[patch.crates-io] cli-engine = { path = "../../cli-engine/cli-engine" }, thencargo build.Test WITHOUT the change:
gddy domain-connect template initprints⚠ missing required argument(s): --provider-id, --provider-name, --service-id, --service-name, then asks "Your domain name, which identifies you as the provider, e.g. acme.com:".Test WITH the change (after
initsetswith_arg_promptfor its four flags): no warning, and the first line on screen is "Provider ID (your domain name):".Cleanup: remove the
[patch.crates-io]entry.🤖 Generated with Claude Code