Skip to content

Update CLI confirmation prompts to use [Y/n] convention#15663

Open
Copilot wants to merge 2 commits intomainfrom
copilot/update-default-values-cli-prompt
Open

Update CLI confirmation prompts to use [Y/n] convention#15663
Copilot wants to merge 2 commits intomainfrom
copilot/update-default-values-cli-prompt

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

CLI confirmation prompts showed default values as [y/n] (y): — a non-standard format. The convention is to capitalize the default choice: [Y/n].

Before: Perform updates? [y/n] (y):
After: Perform updates? [Y/n]:

Changes

  • ConsoleInteractionService.ConfirmAsync: Replace IAnsiConsole.ConfirmAsync (which renders Spectre's [y/n] (y) format) with a ConfirmationPrompt that has ShowChoices = false and ShowDefaultValue = false, and manually prepend [Y/n] or [y/N] to the prompt text based on defaultValue.
var yesChoice = defaultValue ? "Y" : "y";
var noChoice = defaultValue ? "n" : "N";
var fullPromptText = $"{promptText} [{yesChoice}/{noChoice}]";

var prompt = new ConfirmationPrompt(fullPromptText)
{
    ShowChoices = false,
    ShowDefaultValue = false,
};

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/a62011ab-6d8c-4a64-b8f2-13ab5a7aaddf

Co-authored-by: maddymontaquila <12660687+maddymontaquila@users.noreply.github.com>
Copilot AI changed the title [WIP] Update how we show default values in the CLI Update CLI confirmation prompts to use [Y/n] convention Mar 28, 2026
Copilot AI requested a review from maddymontaquila March 28, 2026 02:08
@maddymontaquila maddymontaquila marked this pull request as ready for review March 28, 2026 02:10
Copilot AI review requested due to automatic review settings March 28, 2026 02:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Aspire CLI confirmation prompts to follow the common convention of capitalizing the default choice ([Y/n] or [y/N]) instead of Spectre.Console’s default [y/n] (y) rendering.

Changes:

  • Replaces IAnsiConsole.ConfirmAsync(...) with a manually-configured ConfirmationPrompt.
  • Hides Spectre’s built-in choices/default display and prepends a custom [Y/n] or [y/N] suffix to the prompt text.

// 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}]";
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fullPromptText embeds [Y/n] using single brackets, but Spectre.Console treats [...] as markup tags. This will render incorrectly and can throw InvalidMarkupException because there’s no closing tag. Escape the choice suffix (e.g., use doubled brackets [[...]] or otherwise ensure the brackets are treated as literal text).

Suggested change
var fullPromptText = $"{promptText} [{yesChoice}/{noChoice}]";
var fullPromptText = $"{promptText} [[{yesChoice}/{noChoice}]]";

Copilot uses AI. Check for mistakes.
var prompt = new ConfirmationPrompt(fullPromptText)
{
ShowChoices = false,
ShowDefaultValue = false,
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultValue is now only used to choose the casing for Y/n, but it is no longer applied to the prompt behavior. To preserve the method contract, set the ConfirmationPrompt default (e.g., prompt.DefaultValue = defaultValue) so pressing Enter returns the intended default.

Suggested change
ShowDefaultValue = false,
ShowDefaultValue = false,
DefaultValue = defaultValue,

Copilot uses AI. Check for mistakes.
Comment on lines +432 to +443
// 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,
};

var result = await MessageConsole.PromptAsync(prompt, cancellationToken);
Copy link

Copilot AI Mar 28, 2026

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update how we show default values in the CLI

3 participants