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

Code before:

        parser.addArgument("--consumer.config")
                .action(store())
                .required(false)
                .type(String.class)
                .metavar("CONFIG_FILE")
                .help("(DEPRECATED) Consumer config properties file (config options shared with command line parameters will be overridden)." +
                        "This option will be removed in a future version. Use --command-config instead.");

        parser.addArgument("--command-config")
                .action(store())
                .required(false)
                .type(String.class)
                .metavar("CONFIG-FILE")
                .dest("commandConfigFile")
                .help("Consumer config properties file.");

        return parser;
    }

    public static VerifiableConsumer createFromArgs(ArgumentParser parser, String[] args) throws ArgumentParserException {
        Namespace res = parser.parseArgs(args);

        boolean useAutoCommit = res.getBoolean("useAutoCommit");
        String configFile = res.getString("consumer.config");
        String commandConfigFile = res.getString("command-config");
        String brokerHostAndPort = res.getString("bootstrapServer");

        Properties consumerProps = new Properties();
        if (configFile != null && commandConfigFile != null) {
            throw new ArgumentParserException("Options --consumer.config and --command-config are mutually exclusive.", parser);
        }
        if (configFile != null) {
            try {
                consumerProps.putAll(Utils.loadProps(configFile));
            } catch (IOException e) {
                throw new ArgumentParserException(e.getMessage(), parser);
            }
        }
        if (res.getString(commandConfigFile) != null) {
            try {
                consumerProps.putAll(Utils.loadProps(res.getString(commandConfigFile)));
            } catch (IOException e) {
                throw new ArgumentParserException(e.getMessage(), parser);
            }
        }

        GroupProtocol groupProtocol = GroupProtocol.of(res.getString("groupProtocol"));
        consumerProps.put(ConsumerConfig.GROUP_PROTOCOL_CONFIG, groupProtocol.name());

        // 3.7.0 includes support for KIP-848 which introduced a new implementation of the consumer group protocol.

Review comment (suggestion):
Since you used the destination of `commandConfigFile` on line 623, I would expect you to refer to the string by that name here, unless I'm missing something.

Code after:

        parser.addArgument("--consumer.config")
                .action(store())
                .required(false)
                .type(String.class)
                .metavar("CONFIG-FILE")
                .help("(DEPRECATED) Consumer config properties file" +
                        "This option will be removed in a future version. Use --command-config instead");

        parser.addArgument("--command-config")
                .action(store())
                .required(false)
                .type(String.class)
                .metavar("CONFIG-FILE")
                .dest("commandConfigFile")
                .help("Config properties file (config options shared with command line parameters will be overridden).");

        return parser;
    }

    public static VerifiableConsumer createFromArgs(ArgumentParser parser, String[] args) throws ArgumentParserException {
        Namespace res = parser.parseArgs(args);

        boolean useAutoCommit = res.getBoolean("useAutoCommit");
        String configFile = res.getString("consumer.config");
        String commandConfigFile = res.getString("commandConfigFile");
        String brokerHostAndPort = res.getString("bootstrapServer");

        Properties consumerProps = new Properties();
        if (configFile != null && commandConfigFile != null) {
            throw new ArgumentParserException("Options --consumer.config and --command-config are mutually exclusive.", parser);
        }
        if (configFile != null) {
            System.out.println("Option --consumer.config has been deprecated and will be removed in a future version. Use --command-config instead.");
            try {
                consumerProps.putAll(Utils.loadProps(configFile));
            } catch (IOException e) {
                throw new ArgumentParserException(e.getMessage(), parser);
            }
        }
        if (commandConfigFile != null) {
            try {
                consumerProps.putAll(Utils.loadProps(res.getString(commandConfigFile)));
            } catch (IOException e) {
                throw new ArgumentParserException(e.getMessage(), parser);
            }
        }

        GroupProtocol groupProtocol = GroupProtocol.of(res.getString("groupProtocol"));
        consumerProps.put(ConsumerConfig.GROUP_PROTOCOL_CONFIG, groupProtocol.name());