Skip to content

Commit

Permalink
Trim string results from prompt (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryfu-msft authored Oct 26, 2022
1 parent ce972ca commit 54dbcb7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/WingetCreateCLI/PromptHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,15 @@ public static void PromptValue<T>(string message, object model, string memberNam
Type instanceType = typeof(T);
Type elementType;

if (instanceType == typeof(string) || instanceType == typeof(long))
{
var result = Prompt.Input<T>(message, property.GetValue(model), new[] { FieldValidation.ValidateProperty(model, memberName, instance) });
property.SetValue(model, result);
if (instanceType == typeof(string))
{
string result = Prompt.Input<string>(message, property.GetValue(model), new[] { FieldValidation.ValidateProperty(model, memberName, instance) });
property.SetValue(model, result.Trim());
}
else if (instanceType == typeof(long))
{
long result = Prompt.Input<long>(message, property.GetValue(model), new[] { FieldValidation.ValidateProperty(model, memberName, instance) });
property.SetValue(model, result);
}
else if (instanceType.IsEnum)
{
Expand Down

0 comments on commit 54dbcb7

Please sign in to comment.