Normalize prompt message punctuation across UX primitives#9476
Conversation
|
Azure Pipelines: 20 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
Move the "? " marker and bolded message into a shared renderPromptMessage helper so all four prompt primitives share one definition of the prompt header instead of repeating it. Return an empty separator for blank messages so they no longer render a stray colon, and inspect the last rune rather than the last byte. Update the style guide and provision validation design doc, which still documented the yes/no prompt as "(Y/n):" with a trailing colon. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Centralizes prompt message suffix formatting to avoid duplicated punctuation (?:, ::) and keep UX prompts consistent across primitives.
Changes:
- Added shared prompt message formatting/rendering helpers (
formatPromptMessage,renderPromptMessage). - Integrated the shared helper into Confirm/Prompt/Select/MultiSelect rendering paths.
- Added table-driven tests for suffix formatting and updated docs/examples to match new behavior.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/pkg/ux/prompt_message.go | Introduces shared formatting and rendering helper for prompt messages. |
| cli/azd/pkg/ux/prompt_message_test.go | Adds unit coverage for message suffix formatting edge cases. |
| cli/azd/pkg/ux/confirm.go | Switches Confirm prompt output to shared renderer. |
| cli/azd/pkg/ux/prompt.go | Switches Prompt output to shared renderer. |
| cli/azd/pkg/ux/select.go | Switches Select output to shared renderer. |
| cli/azd/pkg/ux/multi_select.go | Switches MultiSelect output to shared renderer. |
| cli/azd/pkg/ux/confirm_prompt_test.go | Adds assertion to prevent ?: regression in Confirm rendering. |
| cli/azd/docs/style-guidelines/azd-style-guide.md | Documents punctuation rules and updates yes/no delineator format. |
| cli/azd/docs/design/provision-validation.md | Updates example output to use [Y/n] formatting. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 5
- Review effort level: Lite
|
|
||
| All input requests are in bold and begin with a blue `?`. This helps ensure that they stand out to users as different from other plain text logs and CLI outputs. | ||
|
|
||
| Prompt messages carry their own terminal punctuation. A message that already ends in `?`, `:`, `.`, `!`, or `;` is rendered as written; any other message has `:` appended. `Enter a unique environment name` and `Enter a unique environment name:` therefore render identically, so either form is fine. Question-style prompts must supply their own `?`. |
|
|
||
| - Yes/no inputs include a `(Y/n)` delineator at the end of the input request (before the colon). | ||
| - Users can either input `y`/`n` or hit the return key which will select the capitalized choice in the `(Y/n)` delineator. | ||
| - Yes/no inputs include a `[Y/n]` delineator at the end of the input request. Because the message supplies its own punctuation, no colon follows the delineator. |
| func renderPromptMessage(printer Printer, message string) { | ||
| printer.Fprintf("%s", output.WithHighLightFormat("? ")) | ||
| printer.Fprintf("%s", BoldString("%s", formatPromptMessage(message))) | ||
| } |
| func formatPromptMessage(message string) string { | ||
| trimmed := strings.TrimRight(message, " \t\r\n") | ||
| if trimmed == "" { | ||
| return "" | ||
| } |
| func renderPromptMessage(printer Printer, message string) { | ||
| printer.Fprintf("%s", output.WithHighLightFormat("? ")) | ||
| printer.Fprintf("%s", BoldString("%s", formatPromptMessage(message))) | ||
| } |
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Fixes #9475
This PR fixes duplicated punctuation in azd's interactive prompts. The prompt primitives in
pkg/uxappended:to every message regardless of what the caller supplied, so any message that already ended in punctuation rendered with a doubled suffix.Issue
All four prompt primitives formatted their message as
"%s: ", which is correct only for label-style messages. Callers that phrase a prompt as a question, or that supply their own colon, ended up with the separator applied twice.Proceed with provisioning despite the warnings above?rendered as? Proceed with provisioning despite the warnings above?: [Y/n]Select a deployment to continue:rendered as? Select a deployment to continue::Because the duplication came from the shared primitive, it affected every prompt in the CLI as well as the prompts served to extensions through the gRPC prompt service, so fixing it at individual call sites was not viable.
Shared prompt header
Prompt rendering is now defined once rather than repeated across the primitives.
renderPromptMessagewrites the leading?marker and the bolded message, and is called by Confirm, Prompt, Select, and MultiSelect.formatPromptMessagedecides the separator: a message already ending in?,:,.,!, or;receives only a trailing space, and anything else receives:.Callers need no changes.
Enter a unique environment nameandEnter a unique environment name:both renderEnter a unique environment name:, so existing messages in either form continue to display correctly.Documentation
The style guide documented a form the CLI has not produced for some time, and this change moves the rendered output further from it, so both were corrected.
azd-style-guide.mdshowed the yes/no prompt as? ...? (Y/n):; it now shows? ...? [Y/n]and explains that the capitalized letter reflects the default value.(Y/n)delineator in its warning-scenario example.Behaviour at a glance
Continue with reset?? Continue with reset?: [y/N]? Continue with reset? [y/N]Select a deployment to continue:? Select a deployment to continue::? Select a deployment to continue:Enter a unique environment name? Enter a unique environment name:? Enter a unique environment name:Testing
Table-driven coverage for the separator rule spans plain messages, each accepted terminal punctuation character, trailing-whitespace trimming, and the blank and whitespace-only inputs that guard the final-character read. A rendering assertion on the Confirm primitive pins the user-visible behavior so the doubled suffix cannot return unnoticed, and the existing prompt rendering and console interaction suites pass unchanged.