// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. using System.Collections.Generic; using System.Linq; using CommandLine.Core; using CommandLine.Infrastructure; namespace CommandLine { static class ErrorExtensions { public static ParserResult ToParserResult(this IEnumerable errors, T instance) { return errors.Any() ? (ParserResult)new NotParsed(instance.GetType().ToTypeInfo(), errors) : (ParserResult)new Parsed(instance); } public static IEnumerable OnlyMeaningfulOnes(this IEnumerable errors) { return errors .Where(e => !e.StopsProcessing) .Where(e => !(e.Tag == ErrorType.UnknownOptionError && ((UnknownOptionError)e).Token.EqualsOrdinalIgnoreCase("help"))); } } }