コード例 #1
0
ファイル: Program.cs プロジェクト: karanbirsingh/axe-windows
        private int Run()
        {
            Exception caughtException = null;

            try
            {
                using (var parser = CaseInsensitiveParser())
                {
                    parser.ParseArguments <Options>(_args)
                    .WithParsed <Options>(RunWithParsedInputs);
                }
            }
#pragma warning disable CA1031
            catch (Exception e)
#pragma warning restore CA1031
            {
                caughtException = e;
            }

            if (_options != null)
            {
                _outputGenerator.WriteOutput(_options, _scanResults, caughtException);
            }
            return(ReturnValueChooser.GetReturnValue(_scanResults, caughtException));
        }
コード例 #2
0
        private int Run()
        {
            Exception caughtException = null;
            bool      parserError     = false;

            try
            {
                using (var parser = CaseInsensitiveParser())
                {
                    ParserResult <Options> parserResult = parser.ParseArguments <Options>(_args);
                    parserError = parserResult.Tag == ParserResultType.NotParsed;
                    parserResult.WithParsed(RunWithParsedInputs)
                    .WithNotParsed(_ =>
                    {
                        HelpText helpText = HelpText.AutoBuild(parserResult, h =>
                        {
                            h.AutoHelp    = false;      // hides --help
                            h.AutoVersion = false;      // hides --version
                            return(HelpText.DefaultParsingErrorsHandler(parserResult, h));
                        }, e => e);
                        _writer.WriteLine(helpText);
                    });
                }
            }
#pragma warning disable CA1031
            catch (Exception e)
#pragma warning restore CA1031
            {
                caughtException = e;
            }

            if (_options != null)
            {
                IEnumerable <ScanResults> guaranteedScanResults = _scanResultsCollection ?? new List <ScanResults> {
                    null
                };

                foreach (var scanResult in guaranteedScanResults)
                {
                    _outputGenerator.WriteOutput(_options, scanResult, caughtException);
                }
            }
            return(ReturnValueChooser.GetReturnValue(parserError, _scanResultsCollection, caughtException));
        }