Esempio n. 1
0
        /// <summary>
        /// Parses a list of arguments.
        /// </summary>
        /// <param name="arguments">The string array typically passed to a program's <c>Main</c> method.</param>
        /// <param name="rawInput">The complete command line input prior to splitting and tokenization. This input is not typically available when the parser is called from <c>Program.Main</c>. It is primarily used when calculating completions via the <c>dotnet-suggest</c> tool.</param>
        /// <returns>A <see cref="ParseResult"/> providing details about the parse operation.</returns>
        public ParseResult Parse(
            IReadOnlyList <string> arguments,
            string?rawInput = null)
        {
            var tokenizeResult = arguments.Tokenize(
                Configuration,
                inferRootCommand: rawInput is not null);

            var operation = new ParseOperation(
                tokenizeResult,
                Configuration);

            operation.Parse();

            var visitor = new ParseResultVisitor(
                this,
                tokenizeResult,
                operation.UnparsedTokens,
                operation.UnmatchedTokens,
                rawInput);

            visitor.Visit(operation.RootCommandNode !);

            return(visitor.GetResult());
        }
        public override ParseResult Parse(
            IReadOnlyList <string> arguments,
            string rawInput = null)
        {
            var tokenizeResult = arguments.Tokenize(Configuration);

            var operation = new ParseOperation(
                tokenizeResult,
                Configuration);

            operation.Parse();

            var visitor = new ParseResultVisitor(
                this,
                tokenizeResult,
                operation.UnparsedTokens,
                operation.UnmatchedTokens,
                operation.Errors,
                rawInput);

            visitor.Visit(operation.RootCommandNode);

            return(visitor.Result);
        }