public int execute(String[] args, Map<String, String> envVars) {
        boolean debugMode = envVars.containsKey("VESPA_DEBUG");
        try {
            var maybeTool = toolFromCliArgs(args);
            if (maybeTool.isEmpty()) { // This also implicitly covers the top-level --help case.
                CliOptions.printTopLevelHelp(stdOut, TOOLS);
                return 0;
            }
            var tool     = maybeTool.get();
            var toolDesc = tool.description();
            var cliOpts  = CliOptions.withHelpOption(toolDesc.cliOptions());
            String[] truncatedArgs = withToolNameArgRemoved(args);
            var cmdLine = parseCliArguments(truncatedArgs, cliOpts);
            if (cmdLine.hasOption("help")) {
                CliOptions.printToolSpecificHelp(stdOut, tool.name(), toolDesc, cliOpts);
                return 0;
            }
            var invocation = new ToolInvocation(cmdLine, envVars, stdIn, stdOut, stdError, consoleInputOrNull, debugMode);
            return tool.invoke(invocation);
        } catch (ParseException e) {
            return handleException("Failed to parse command line arguments: " + e.getMessage(), e, debugMode);
        } catch (IllegalArgumentException e) {
            return handleException("Invalid command line arguments: " + e.getMessage(), e, debugMode);
        } catch (Exception e) {
            return handleException("Got unhandled exception: " + e.getMessage(), e, debugMode);
        }
    }
Primary application entry point for security utility tools. Handles tool selection,
CLI argument parsing and exception printing.

Based on previous vespa-security-env tool.

@author vekterli
@author bjorncs
vespaclient-java/src/main/java/com/yahoo/vespa/security/tool/Main.java