BadScript 2
Loading...
Searching...
No Matches
ErrorExtensions.cs
Go to the documentation of this file.
1// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
2
3using System.Collections.Generic;
4using System.Linq;
5
8
9namespace CommandLine
10{
11 internal static class ErrorExtensions
12 {
13 public static ParserResult<T> ToParserResult<T>(this IEnumerable<Error> errors, T instance)
14 {
15 return errors.Any()
16 ? new NotParsed<T>(instance.GetType()
17 .ToTypeInfo(),
18 errors
19 )
20 : (ParserResult<T>)new Parsed<T>(instance);
21 }
22
23 public static IEnumerable<Error> OnlyMeaningfulOnes(this IEnumerable<Error> errors)
24 {
25 return errors
26 .Where(e => !e.StopsProcessing)
27 .Where(e => !(e.Tag == ErrorType.UnknownOptionError &&
28 ((UnknownOptionError)e).Token.EqualsOrdinalIgnoreCase("help"))
29 );
30 }
31 }
32}
static IEnumerable< Error > OnlyMeaningfulOnes(this IEnumerable< Error > errors)
static ParserResult< T > ToParserResult< T >(this IEnumerable< Error > errors, T instance)
It contains a sequence of CommandLine.Error.
It contains an instance of type T with parsed values.
Models a parser result. When inherited by CommandLine.Parsed<T>, it contains an instance of type T w...
Models an error generated when an unknown option is detected.
Definition Error.cs:383
ErrorType
Discriminator enumeration of CommandLine.Error derivates.
Definition Error.cs:13