Repository: apache/kafka
File: tools/src/main/java/org/apache/kafka/tools/FeatureCommand.java (Java)

Code before:
        addUpgradeParser(subparsers);
        addDowngradeParser(subparsers);
        addDisableParser(subparsers);
        addVersionMappingParser(subparsers);
        addFeatureDependenciesParser(subparsers);

        Namespace namespace = parser.parseArgs(args);
        String command = namespace.getString("command");
        if (command.equals("version-mapping")) {
            handleVersionMapping(namespace, Feature.PRODUCTION_FEATURES);
            return;
        } else if (command.equals("feature-dependencies")) {
            handleFeatureDependencies(namespace, Feature.PRODUCTION_FEATURES);
            return;
        }
        String configPath = namespace.getString("command_config");
        Properties properties = (configPath == null) ? new Properties() : Utils.loadProps(configPath);

        try {
            CommandLineUtils.initializeBootstrapProperties(properties,
                    Optional.ofNullable(namespace.getString("bootstrap_server")),
                    Optional.ofNullable(namespace.getString("bootstrap_controller")));
        } catch (Exception e) {
            // bootstrap_server and bootstrap_controller are in a mutually exclusive group,
            // so the exception happens only when both of them are missing
            throw new ArgumentParserException("one of the arguments --bootstrap-server --bootstrap-controller is required", parser);
        }

        try (Admin adminClient = Admin.create(properties)) {
            switch (command) {
                case "describe":
                    handleDescribe(adminClient);
                    break;
                case "upgrade":
                    handleUpgrade(namespace, adminClient);
                    break;
                case "downgrade":
                    handleDowngrade(namespace, adminClient);
                    break;
                case "disable":
                    handleDisable(namespace, adminClient);
                    break;
                default:
                    throw new TerseException("Unknown command " + command);
            }
        }
    }

    private static void addDescribeParser(Subparsers subparsers) {
        subparsers.addParser("describe")
                .help("Describes the current active feature flags.");

Review comment (suggestion):
How about `new ArgumentParserException(e.getMessage(), parser)`

Code after:
        addUpgradeParser(subparsers);
        addDowngradeParser(subparsers);
        addDisableParser(subparsers);
        addVersionMappingParser(subparsers);
        addFeatureDependenciesParser(subparsers);

        Namespace namespace = parser.parseArgs(args);
        String command = namespace.getString("command");
        if (command.equals("version-mapping")) {
            handleVersionMapping(namespace, Feature.PRODUCTION_FEATURES);
            return;
        } else if (command.equals("feature-dependencies")) {
            handleFeatureDependencies(namespace, Feature.PRODUCTION_FEATURES);
            return;
        }
        String configPath = namespace.getString("command_config");
        Properties properties = (configPath == null) ? new Properties() : Utils.loadProps(configPath);

        try {
            CommandLineUtils.initializeBootstrapProperties(properties,
                    Optional.ofNullable(namespace.getString("bootstrap_server")),
                    Optional.ofNullable(namespace.getString("bootstrap_controller")));
        } catch (Exception e) {
            // bootstrap_server and bootstrap_controller are in a mutually exclusive group,
            // so the exception happens only when both of them are missing
            throw new ArgumentParserException(e.getMessage(), parser);
        }

        try (Admin adminClient = Admin.create(properties)) {
            switch (command) {
                case "describe":
                    handleDescribe(adminClient);
                    break;
                case "upgrade":
                    handleUpgrade(namespace, adminClient);
                    break;
                case "downgrade":
                    handleDowngrade(namespace, adminClient);
                    break;
                case "disable":
                    handleDisable(namespace, adminClient);
                    break;
                default:
                    throw new TerseException("Unknown command " + command);
            }
        }
    }

    private static void addDescribeParser(Subparsers subparsers) {
        subparsers.addParser("describe")
                .help("Describes the current active feature flags.");