static async Task Main()

in JetBrains.SbomUtils/src/JetBrains.SbomUtils.Console/Program.cs [19:95]


    static async Task<int> Main(string[] args)
    {
        RootCommand rootCommand = new RootCommand(
            description: "Analyze that the installed software complies with the SBOM.");

        var analyzeSingle = new Command("analyze", "Analyze that the installed software complies with the SBOM.");
        var analyzeBatch = new Command("analyze-batch", "Analyze that all installed software in the provided json complies with the SBOM.");

        rootCommand.AddCommand(analyzeSingle);
        rootCommand.AddCommand(analyzeBatch);

        var programRootDirectory = new Option<string>(
            aliases: ["--path", "-p"],
            description: "The path to the installed software.")
        {
            Arity = ArgumentArity.ExactlyOne
        };

        var sbomFileOption = new Option<string>(
            aliases: ["--sbom", "-s"],
            description: "The path to the SBOM in SPDX 2.3 format.")
        {
            Arity = ArgumentArity.ExactlyOne
        };

        var rootPackage = new Option<string[]>(
            aliases: ["--root-package", "-r"],
            description: "One or multiple root packages.")
        {
            Arity = ArgumentArity.ZeroOrMore,
            AllowMultipleArgumentsPerToken = true,
        };

        var exemptionsOption = new Option<string[]>(
            aliases: ["--ignore", "-i"],
            description: "Files and file patterns to ignore.")
        {
            Arity = ArgumentArity.ZeroOrMore,
            AllowMultipleArgumentsPerToken = true,
        };

        var jsonConfigOption = new Option<string>(
            aliases: ["--json-config", "-j"],
            description: "Projects configuration in json file")
        {
            Arity = ArgumentArity.ZeroOrOne,
        };

        var verboseOption = new Option<bool>(
            aliases: ["--verbose", "-v"],
            description: "Write verbose logs")
        {
            Arity = ArgumentArity.ZeroOrOne,
        };
        analyzeBatch.AddOption(jsonConfigOption);

        rootCommand.AddGlobalOption(sbomFileOption);
        rootCommand.AddGlobalOption(verboseOption);

        analyzeSingle.AddOption(programRootDirectory);
        analyzeSingle.AddOption(rootPackage);
        analyzeSingle.AddOption(exemptionsOption);

        analyzeSingle.SetHandler((rootDirectory, sbom, rootPackages, exemptions, verbose) => Analyze(sbom, rootDirectory, rootPackages, exemptions, verbose),
            programRootDirectory,
            sbomFileOption,
            rootPackage,
            exemptionsOption,
            verboseOption);

        analyzeBatch.SetHandler((sbom, jsonConfig, verbose) => AnalyzeBatch(sbom, jsonConfig, verbose),
            sbomFileOption,
            jsonConfigOption,
            verboseOption);

 return await rootCommand.InvokeAsync(args);
    }