Beispiel #1
0
        public int Execute(params string[] args)
        {
            _args = args;
            ParseArgs();
            bool needsReparse = false;

            if (ExtraArgsFileNames != null && ExtraArgsFileNames.Count > 0)
            {   // add the extra args to the _args and force a reparse
                // This cannot adjust the template name, so no need to re-check here.
                IReadOnlyList <string> extraArgs = AppExtensions.CreateArgListFromAdditionalFiles(ExtraArgsFileNames);
                List <string>          allArgs   = RemoveExtraArgsTokens(_args);
                allArgs.AddRange(extraArgs);
                _args                  = allArgs;
                needsReparse           = true;
                ExpandedExtraArgsFiles = true;
            }

            if (string.IsNullOrEmpty(_templateNameArg))
            {
                _currentCommand = CommandParserSupport.CreateNewCommandForNoTemplateName(_commandName);
                needsReparse    = true;
            }

            if (needsReparse)
            {
                ParseArgs();
            }

            return(_invoke.Invoke().Result);
        }
        public int Execute(params string[] args)
        {
            _args = args;
            ParseArgs();
            bool needsReparse = false;

            if (ExtraArgsFileNames != null && ExtraArgsFileNames.Count > 0)
            {   // add the extra args to the _args and force a reparse
                IReadOnlyList <string> extraArgs = AppExtensions.CreateArgListFromAdditionalFiles(ExtraArgsFileNames);
                List <string>          allArgs   = new List <string>(_args);
                allArgs.AddRange(extraArgs);
                _args        = allArgs;
                needsReparse = true;
            }

            IList <string> templateNameList = _parseResult.GetArgumentListAtPath(new[] { _commandName }).ToList();

            if ((templateNameList.Count > 0) &&
                !templateNameList[0].StartsWith("-", StringComparison.Ordinal) &&
                (_parseResult.Tokens.Count >= 2) &&
                string.Equals(templateNameList[0], _parseResult.Tokens.ElementAt(1), StringComparison.Ordinal))
            {
                _templateNameArg = templateNameList[0];
            }
            else
            {
                _templateNameArg = string.Empty;
                _currentCommand  = CommandParserSupport.CreateNewCommandForNoTemplateName(_commandName);
                needsReparse     = true;
            }

            if (needsReparse)
            {
                ParseArgs();
            }

            return(_invoke.Invoke().Result);
        }