Skip to content

Commit

Permalink
(GH-8) Refine Posh Prompting
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ferventcoder committed Mar 14, 2016
1 parent 8289f01 commit 7c2a76c
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ private static string[] get_hotkey_and_label(string input)

public override int PromptForChoice(string caption, string message, Collection<ChoiceDescription> 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);

Expand All @@ -208,14 +209,14 @@ public override int PromptForChoice(string caption, string message, Collection<C
{
choicePrompt.Append(String.Format(
CultureInfo.CurrentCulture,
"|{0}> {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)
Expand Down Expand Up @@ -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:");
Expand Down

0 comments on commit 7c2a76c

Please sign in to comment.