Пример #1
0
        private static Options ParseOptions(string[] toolArgs)
        {
            var opts = new OptionsBuilder(Options.Defaults);

            var cli = new CommandLineUtilities(toolArgs);

            foreach (var opt in cli.Options)
            {
                switch (opt.Name.TrimEnd('-', '+'))
                {
                case ArgVerbose:
                case "v":
                    opts.Verbose = CommandLineUtilities.ParseBooleanOption(opt);
                    break;

                case ArgLogToStdOut:
                case "o":
                    opts.LogToStdOut = CommandLineUtilities.ParseBooleanOption(opt);
                    break;

                case "numKextConnections":
                case "c":
                    Console.WriteLine($"*** WARNING *** option /{opt.Name} has no effect any longer");
                    break;

                case ArgReportQueueSizeMB:
                case "r":
                    opts.ReportQueueSizeMB = CommandLineUtilities.ParseUInt32Option(opt, 1, 1024);
                    break;

                case ArgEnableReportBatching:
                case "b":
                    opts.EnableReportBatching = CommandLineUtilities.ParseBooleanOption(opt);
                    break;

                case ArgEnableStatistics:
                case "s":
                    opts.EnableTelemetry = CommandLineUtilities.ParseBooleanOption(opt);
                    break;

                case ArgProcessTimeout:
                case "t":
                    // Max is currently set to 4 hours and should suffice
                    opts.ProcessTimeout = CommandLineUtilities.ParseInt32Option(opt, (int)s_defaultProcessTimeOut, (int)s_defaultProcessTimeOutMax);
                    break;

                case ArgTrackDirectoryCreation:
                case "d":
                    opts.TrackDirectoryCreation = CommandLineUtilities.ParseBooleanOption(opt);
                    break;

                default:
                    throw new InvalidArgumentException($"Unrecognized option {opt.Name}");
                }
            }

            return(opts.Finish());
        }