33 lines
849 B
C#
33 lines
849 B
C#
|
using System.Collections.Generic;
|
|||
|
using System.CommandLine;
|
|||
|
using System.CommandLine.Parsing;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace MfGames.ToolBuilder.Extensions
|
|||
|
{
|
|||
|
public static class ParseResultExtensions
|
|||
|
{
|
|||
|
public static List<string> ValueListForOption(
|
|||
|
this ParseResult result,
|
|||
|
Option<string> option)
|
|||
|
{
|
|||
|
string? optionValues = result.ValueForOption(option);
|
|||
|
|
|||
|
if (optionValues == null)
|
|||
|
{
|
|||
|
return new List<string>();
|
|||
|
}
|
|||
|
|
|||
|
var values = optionValues
|
|||
|
.Split(',')
|
|||
|
.Select(x => x.Trim())
|
|||
|
.SelectMany(x => x.Split(' '))
|
|||
|
.Select(x => x.Trim())
|
|||
|
.Where(x => !string.IsNullOrWhiteSpace(x))
|
|||
|
.ToList();
|
|||
|
|
|||
|
return values;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|