public static void Configure()

in DevSkim-DotNet/Microsoft.DevSkim.CLI/Commands/AnalyzeCommand.cs [80:183]


        public static void Configure(CommandLineApplication command)
        {
            command.Description = "Analyze source code";
            command.HelpOption("-?|-h|--help");

            var locationArgument = command.Argument("[path]",
                                                    "Path to source code");

            var outputArgument = command.Argument("[output]",
                                                  "Output file");

            var outputFileFormat = command.Option("-f|--file-format",
                                                  "Output file format: [text,json,sarif]",
                                                  CommandOptionType.SingleValue);

            var outputTextFormat = command.Option("-o|--output-format",
                                                  "Output format for text writer or elements to include for json writer.",
                                                  CommandOptionType.SingleValue);

            var severityOption = command.Option("-s|--severity",
                                                "Severity: [critical,important,moderate,practice,manual]",
                                                CommandOptionType.SingleValue);

            var globOptions = command.Option("-g|--ignore-globs",
                                    "**/.git/**,**/bin/**",
                                    CommandOptionType.SingleValue);

            var disableSuppressionOption = command.Option("-d|--disable-suppression",
                                                   "Disable suppression of findings with ignore comments",
                                                   CommandOptionType.NoValue);

            var disableParallel = command.Option("--disable-parallel",
                                       "Disable parallel processing.",
                                       CommandOptionType.NoValue);

            var rulesOption = command.Option("-r|--rules",
                                             "Rules to use. Comma delimited.",
                                             CommandOptionType.SingleValue);

            var ignoreOption = command.Option("-i|--ignore-default-rules",
                                              "Ignore rules bundled with DevSkim",
                                              CommandOptionType.NoValue);

            var errorOption = command.Option("-e|--suppress-standard-error",
                                              "Suppress output to standard error",
                                              CommandOptionType.NoValue);

            var crawlArchives = command.Option("-c|--crawl-archives",
                                       "Enable crawling into archives when processing directories.",
                                       CommandOptionType.NoValue);

            var exitCodeIsNumIssues = command.Option("-E",
                                        "Use the exit code to indicate number of issues identified.",
                                        CommandOptionType.NoValue);

            var basePath = command.Option("--base-path",
                                        "Specify what path to root result URIs with. When not set will generate paths relative to the source directory (or directory containing the source file specified).",
                                        CommandOptionType.SingleValue);

            var absolutePaths = command.Option("--absolute-path",
                           "Output absolute paths (overrides --base-path).",
                           CommandOptionType.NoValue);

            command.ExtendedHelpText = 
@"
Output format options:
%F  file path
%L  start line number
%C  start column
%l  end line number
%c  end column
%I  location inside file
%i  match length
%m  match
%R  rule id
%N  rule name
%S  severity
%D  issue description
%T  tags (comma-separated in text writer)
%f  fixes (json only)";

            command.OnExecute((Func<int>)(() =>
            {
                var opts = new AnalyzeCommandOptions()
                {
                    Path = locationArgument.Value,
                    OutputFile = outputArgument.Value,
                    OutputFileFormat = outputFileFormat.Value(),
                    OutputTextFormat = outputTextFormat.Value(),
                    Severities = severityOption.Value()?.Split(',') ?? Array.Empty<string>(),
                    Rulespath = rulesOption.Value()?.Split(',') ?? Array.Empty<string>(),
                    IgnoreDefaultRules = ignoreOption.HasValue(),
                    SuppressError = errorOption.HasValue(),
                    DisableSuppression = disableSuppressionOption.HasValue(),
                    CrawlArchives = crawlArchives.HasValue(),
                    ExitCodeIsNumIssues = exitCodeIsNumIssues.HasValue(),
                    Globs = globOptions.Value()?.Split(',').Select<string, Glob>(x => new Glob(x)) ?? Array.Empty<Glob>(),
                    BasePath = basePath.Value(),
                    DisableParallel = disableParallel.HasValue(),
                    AbsolutePaths = absolutePaths.HasValue()
                };
                return (new AnalyzeCommand(opts).Run());
            }));
        }