This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-toolbuilder-cil/src/MfGames.ToolBuilder/Extensions/ParseResultExtensions.cs

33 lines
849 B
C#
Raw Normal View History

2021-09-10 17:33:42 +00:00
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;
}
}
}