-
Notifications
You must be signed in to change notification settings - Fork 852
Update CLI confirmation prompts to use [Y/n] convention #15663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -428,7 +428,19 @@ public async Task<bool> ConfirmAsync(string promptText, bool defaultValue = true | |||||||
| } | ||||||||
|
|
||||||||
| MessageLogger.LogInformation("Confirm: {PromptText} (default: {DefaultValue})", promptText, defaultValue); | ||||||||
| var result = await MessageConsole.ConfirmAsync(promptText, defaultValue, cancellationToken); | ||||||||
|
|
||||||||
| // Use [Y/n] or [y/N] convention where the capitalized letter indicates the default value. | ||||||||
| var yesChoice = defaultValue ? "Y" : "y"; | ||||||||
| var noChoice = defaultValue ? "n" : "N"; | ||||||||
| var fullPromptText = $"{promptText} [{yesChoice}/{noChoice}]"; | ||||||||
|
|
||||||||
| var prompt = new ConfirmationPrompt(fullPromptText) | ||||||||
| { | ||||||||
| ShowChoices = false, | ||||||||
| ShowDefaultValue = false, | ||||||||
|
||||||||
| ShowDefaultValue = false, | |
| ShowDefaultValue = false, | |
| DefaultValue = defaultValue, |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change alters interactive prompt rendering/behavior but there are no tests validating the new [Y/n] formatting or the default-value semantics (Enter should select the configured default). Consider adding a focused unit test around ConfirmAsync similar to the existing ConsoleInteractionServiceTests patterns to prevent regressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fullPromptTextembeds[Y/n]using single brackets, but Spectre.Console treats[...]as markup tags. This will render incorrectly and can throwInvalidMarkupExceptionbecause there’s no closing tag. Escape the choice suffix (e.g., use doubled brackets[[...]]or otherwise ensure the brackets are treated as literal text).