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
Dylan R. E. Moonfire ad0525be04 feat: initial commit
2021-09-10 12:33:42 -05:00

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;
}
}
}