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

Code before:
        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.
        // The two implementations use slightly different configuration, hence these arguments are conditional.
        //
        // See the Python class/method VerifiableConsumer.start_cmd() in verifiable_consumer.py for how the
        // command line arguments are passed in by the system test framework.
        if (groupProtocol == GroupProtocol.CONSUMER) {
            String groupRemoteAssignor = res.getString("groupRemoteAssignor");

            if (groupRemoteAssignor != null)
                consumerProps.put(ConsumerConfig.GROUP_REMOTE_ASSIGNOR_CONFIG, groupRemoteAssignor);

Review comment (suggestion):
Please add a deprecation message here like `System.out.println("Option --consumer.config has been deprecated and will be removed in a future version. Use --command-config instead.");`.

Code after:
        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());

        // 3.7.0 includes support for KIP-848 which introduced a new implementation of the consumer group protocol.
        // The two implementations use slightly different configuration, hence these arguments are conditional.
        //
        // See the Python class/method VerifiableConsumer.start_cmd() in verifiable_consumer.py for how the
        // command line arguments are passed in by the system test framework.
        if (groupProtocol == GroupProtocol.CONSUMER) {
            String groupRemoteAssignor = res.getString("groupRemoteAssignor");

            if (groupRemoteAssignor != null)