private static string GetOptionText(ICommandLineParserError error)
        {
            var optionText = error.Option.LongName.IsNullOrWhiteSpace()
                                 ? error.Option.ShortName
                                 : error.Option.ShortName + ":" + error.Option.LongName;

            return(optionText);
        }
		/// <summary>
		/// Formats the specified <see cref="ICommandLineParserError"/> to a <see cref="System.String"/> suitable for the end user.
		/// </summary>
		/// <param name="parserError">The error to format. This must not be null.</param>
		/// <returns>A <see cref="System.String"/> describing the specified error.</returns>
		public string Format(ICommandLineParserError parserError)
		{
			var optionSyntaxParseError = parserError as OptionSyntaxParseError;
			if (optionSyntaxParseError != null) return FormatOptionSyntaxParseError(optionSyntaxParseError);

			var expectedOptionNotFoundError = parserError as ExpectedOptionNotFoundParseError;
			if (expectedOptionNotFoundError != null) return FormatExpectedOptionNotFoundError(expectedOptionNotFoundError);

			return "unknown parse error.";
		}
Esempio n. 3
0
        /// <summary>
        /// Formats the specified <see cref="ICommandLineParserError"/> to a <see cref="System.String"/> suitable for the end user.
        /// </summary>
        /// <param name="parserError">The error to format. This must not be null.</param>
        /// <returns>A <see cref="System.String"/> describing the specified error.</returns>
        public string Format(ICommandLineParserError parserError)
        {
            if (parserError is OptionSyntaxParseError optionSyntaxParseError)
            {
                return(FormatOptionSyntaxParseError(optionSyntaxParseError));
            }

            if (parserError is ExpectedOptionNotFoundParseError expectedOptionNotFoundError)
            {
                return(FormatExpectedOptionNotFoundError(expectedOptionNotFoundError));
            }

            return("unknown parse error.");
        }
        /// <summary>
        /// Formats the specified <see cref="ICommandLineParserError"/> to a <see cref="System.String"/> suitable for the end user.
        /// </summary>
        /// <param name="parserError">The error to format. This must not be null.</param>
        /// <returns>A <see cref="System.String"/> describing the specified error.</returns>
        public string Format(ICommandLineParserError parserError)
        {
            var optionSyntaxParseError = parserError as OptionSyntaxParseError;

            if (optionSyntaxParseError != null)
            {
                return(FormatOptionSyntaxParseError(optionSyntaxParseError));
            }

            var expectedOptionNotFoundError = parserError as ExpectedOptionNotFoundParseError;

            if (expectedOptionNotFoundError != null)
            {
                return(FormatExpectedOptionNotFoundError(expectedOptionNotFoundError));
            }

            return("unknown parse error.");
        }
		private static string GetOptionText(ICommandLineParserError error)
		{
			var optionText = error.Option.LongName.IsNullOrWhiteSpace()
				                 ? error.Option.ShortName
				                 : error.Option.ShortName + ":" + error.Option.LongName;
			return optionText;
		}