Skip to content

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

Merged
JamesNK merged 3 commits intomainfrom
copilot/update-default-values-cli-prompt
Apr 8, 2026
Merged

Update CLI confirmation prompts to use [Y/n] convention#15663
JamesNK merged 3 commits intomainfrom
copilot/update-default-values-cli-prompt

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

Description

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: Replaced IAnsiConsole.ConfirmAsync (which renders Spectre's [y/n] (y) format) with a ConfirmationPrompt that has ShowChoices = false and ShowDefaultValue = false, with [Y/n] or [y/N] manually appended to the prompt text based on defaultValue. Brackets are escaped using Spectre.Console's [[...]] syntax to produce literal bracket characters. DefaultValue is explicitly set on the prompt so pressing Enter returns the correct configured default.
var yesChoice = defaultValue ? "Y" : "y";
var noChoice = defaultValue ? "n" : "N";
var fullPromptText = $"{promptText} [[{yesChoice}/{noChoice}]]";

var prompt = new ConfirmationPrompt(fullPromptText)
{
    ShowChoices = false,
    ShowDefaultValue = false,
    DefaultValue = defaultValue,
};
  • Tests: Added ConfirmAsync_DisplaysCapitalizedDefaultChoice to verify that [Y/n] or [y/N] appears in the prompt output based on the default value. Added ConfirmAsync_WhenUserPressesEnter_ReturnsDefaultValue to verify that pressing Enter accepts the configured default. Both tests use a new TestAnsiConsoleWithInput helper that feeds predefined keystrokes so prompts don't block on real console input.

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.
Comment thread src/Aspire.Cli/Interaction/ConsoleInteractionService.cs
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.
@JamesNK
Copy link
Copy Markdown
Member

JamesNK commented Mar 29, 2026

This is inconsistent with text inputs. They display the default in parenthesis. Is it normal for CLIs to have different standards between text inputs and Yes/No.

Also, this isn't localized. What about other languages?

@maddymontaquila
Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15663

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15663"

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot apply changes based on the comments in this thread

Applied all three fixes from the review thread in commit 996d350:

  1. Bracket escaping: Changed [{yesChoice}/{noChoice}] to [[{yesChoice}/{noChoice}]] so Spectre.Console renders literal [Y/n] rather than trying to parse it as a markup tag.
  2. DefaultValue: Added DefaultValue = defaultValue to ConfirmationPrompt so pressing Enter returns the correct configured default.
  3. Tests: Added ConfirmAsync_DisplaysCapitalizedDefaultChoice (verifies [Y/n]/[y/N] appears in output) and ConfirmAsync_WhenUserPressesEnter_ReturnsDefaultValue (verifies Enter accepts the default), using a TestAnsiConsoleWithInput wrapper to simulate keyboard input.

This is inconsistent with text inputs. They display the default in parenthesis. Is it normal for CLIs to have different standards between text inputs and Yes/No.

Also, this isn't localized. What ab...

The [Y/n] convention is the standard for boolean yes/no prompts across most CLIs (git, npm, pip, etc.) and is different from text prompts where a default value in parentheses makes sense because it shows the actual value being defaulted to. For yes/no, capitalizing the letter is the value — it's a widely understood shorthand.

Regarding localization: the y/n characters in confirmation prompts are typically not localized in CLIs (even in non-English systems, y/n remains universal). The Spectre.Console ConfirmationPrompt itself uses y/n unconditionally. This matches the behavior of nearly all major CLIs. If we want to localize in the future, the ConfirmationPrompt.Yes and ConfirmationPrompt.No properties can be set, but that would be a separate effort.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dnceng.pkgs.visualstudio.com
    • Triggering command: .dotnet/dotnet .dotnet/dotnet build tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj -v quiet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@maddymontaquila
Copy link
Copy Markdown
Contributor

This is inconsistent with text inputs. They display the default in parenthesis. Is it normal for CLIs to have different standards between text inputs and Yes/No.

Also, this isn't localized. What about other languages?

Text inputs should be treated separately, yeah.

Y/n or y/N is the standard in like all linux/unix scripts so for boolean answers we should standadrdize on that

@JamesNK JamesNK merged commit 91ee0cf into main Apr 8, 2026
263 checks passed
@JamesNK JamesNK deleted the copilot/update-default-values-cli-prompt branch April 8, 2026 04:59
@aspire-repo-bot
Copy link
Copy Markdown
Contributor

📄 Documentation Check: No documentation updates required.

This PR changes CLI confirmation prompt formatting from [y/n] (y): to [Y/n]: — a cosmetic/UX improvement that follows standard conventions. Since this is an internal implementation change with no new public APIs, new features, or breaking behavioral changes, no updates to the [Aspire docs site]((learn.microsoft.com/redacted) are needed.

Generated by PR Documentation Check for issue #15663 · ● 126.4K ·

@joperezr joperezr added this to the 13.3 milestone Apr 14, 2026
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

7 participants