C# Класс SonarQube.Common.CommandLineParser

Process and validates the command line arguments and reports any errors
The command line parsing makes a number of simplifying assumptions: * order is unimportant * all arguments have a recognizable prefix e.g. /key= * the first matching prefix will be used (so if descriptors have overlapping prefixes they need to be supplied to the parser in the correct order on construction) * the command line arguments are those supplied in Main(args) i.e. they have been converted from a string to an array by the runtime. This means that quoted arguments will already have been partially processed so a command line of: myApp.exe "quoted arg" /k="ab cd" "" will be supplied as three args, [quoted arg] , [/k=ab cd] and String.Empty
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
CommandLineParser ( IEnumerable descriptors, bool allowUnrecognized ) : System

Constructs a command line parser

ParseArguments ( string commandLineArgs, ILogger logger, IEnumerable &argumentInstances ) : bool

Parses the supplied arguments. Logs errors for unrecognized, duplicate or missing arguments.

Приватные методы

Метод Описание
CheckRequiredArgumentsSupplied ( IEnumerable arguments, ILogger logger ) : bool

Checks whether any required arguments are missing and logs error messages for them.

IdExists ( string id, IEnumerable arguments ) : bool
TryGetMatchingDescriptor ( string argument, SonarQube.Common.ArgumentDescriptor &descriptor, string &prefix ) : bool

Attempts to find a descriptor for the current argument

TryGetMatchingPrefix ( SonarQube.Common.ArgumentDescriptor descriptor, string argument ) : string

Описание методов

CommandLineParser() публичный Метод

Constructs a command line parser
public CommandLineParser ( IEnumerable descriptors, bool allowUnrecognized ) : System
descriptors IEnumerable List of descriptors that specify the valid argument types
allowUnrecognized bool True if unrecognized arguments should be ignored
Результат System

ParseArguments() публичный Метод

Parses the supplied arguments. Logs errors for unrecognized, duplicate or missing arguments.
public ParseArguments ( string commandLineArgs, ILogger logger, IEnumerable &argumentInstances ) : bool
commandLineArgs string
logger ILogger
argumentInstances IEnumerable A list of argument instances that have been recognized
Результат bool