From 7c2a76c7fad9117b4a37595d85ad21729f46828d Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Mon, 14 Mar 2016 07:51:13 -0500 Subject: [PATCH] (GH-8) Refine Posh Prompting Both the caption and the message should be displayed to users during PowerShell prompting. The choices menu should look more similar to how it would originally look in PowerShell. --- .../powershell/PoshHostUserInterface.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/chocolatey/infrastructure/powershell/PoshHostUserInterface.cs b/src/chocolatey/infrastructure/powershell/PoshHostUserInterface.cs index 191070e1a2..fa2bffe2bf 100644 --- a/src/chocolatey/infrastructure/powershell/PoshHostUserInterface.cs +++ b/src/chocolatey/infrastructure/powershell/PoshHostUserInterface.cs @@ -198,7 +198,8 @@ private static string[] get_hotkey_and_label(string input) public override int PromptForChoice(string caption, string message, Collection choices, int defaultChoice) { - this.Log().Warn(caption.escape_curly_braces()); + if (!string.IsNullOrWhiteSpace(caption)) this.Log().Warn(caption.escape_curly_braces()); + if (!string.IsNullOrWhiteSpace(message)) this.Log().Warn(ChocolateyLoggers.Important, message.escape_curly_braces()); string[,] promptData = build_hotkeys_and_plain_labels(choices); @@ -208,14 +209,14 @@ public override int PromptForChoice(string caption, string message, Collection {1} ", + "[{0}] {1} ", promptData[0, element], promptData[1, element])); } choicePrompt.Append(String.Format( CultureInfo.CurrentCulture, - "[Default is ({0}]", + "(default is \"{0}\")", promptData[0, defaultChoice])); while (true) @@ -255,7 +256,9 @@ public override PSCredential PromptForCredential(string caption, string message, public override PSCredential PromptForCredential(string caption, string message, string userName, string targetName, PSCredentialTypes allowedCredentialTypes, PSCredentialUIOptions options) { - this.Log().Warn(caption.escape_curly_braces()); + if (!string.IsNullOrWhiteSpace(caption)) this.Log().Warn(caption.escape_curly_braces()); + if (!string.IsNullOrWhiteSpace(message)) this.Log().Warn(ChocolateyLoggers.Important, message.escape_curly_braces()); + if (string.IsNullOrWhiteSpace(userName)) { this.Log().Warn("Please provide username:");