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

Code before:
                .withRequiredArg()
                .describedAs("number-of-offsets")
                .ofType(Long.class);
            configOption = parser.accepts("config-file", "(DEPRECATED) Property file containing configs to be passed to admin clients and embedded consumer. "
                    + "This option will be removed in a future version. Use --command-config instead.")
                .withRequiredArg()
                .ofType(String.class)
                .describedAs("file name");
            commandConfigOption = parser.accepts("command-config", "Config properties file to be passed to admin clients and embedded consumer.")
                .withRequiredArg()
                .ofType(String.class)
                .describedAs("file name");
            forceOption = parser.accepts("force", "Force the removal of members of the consumer group (intended to remove stopped members if a long session timeout was used). " +
                "Make sure to shut down all stream applications when this option is specified to avoid unexpected rebalances.");

            dryRunOption = parser.accepts("dry-run", "Display the actions that would be performed without executing the reset commands.");

            try {
                options = parser.parse(args);
                if (CommandLineUtils.isPrintHelpNeeded(this)) {
                    CommandLineUtils.printUsageAndExit(parser, USAGE);
                }
                if (CommandLineUtils.isPrintVersionNeeded(this)) {
                    CommandLineUtils.printVersionAndExit();
                }
                CommandLineUtils.checkRequiredArgs(parser, options, bootstrapServerOption);
                CommandLineUtils.checkInvalidArgs(parser, options, toOffsetOption, toDatetimeOption, byDurationOption, toEarliestOption, toLatestOption, fromFileOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, toDatetimeOption, toOffsetOption, byDurationOption, toEarliestOption, toLatestOption, fromFileOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, byDurationOption, toOffsetOption, toDatetimeOption, toEarliestOption, toLatestOption, fromFileOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, toEarliestOption, toOffsetOption, toDatetimeOption, byDurationOption, toLatestOption, fromFileOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, toLatestOption, toOffsetOption, toDatetimeOption, byDurationOption, toEarliestOption, fromFileOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, fromFileOption, toOffsetOption, toDatetimeOption, byDurationOption, toEarliestOption, toLatestOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, shiftByOption, toOffsetOption, toDatetimeOption, byDurationOption, toEarliestOption, toLatestOption, fromFileOption);
                CommandLineUtils.checkInvalidArgs(parser, options, configOption, commandConfigOption);
            } catch (final OptionException e) {
                CommandLineUtils.printUsageAndExit(parser, e.getMessage());
            }
        }

        public boolean hasDryRun() {
            return options.has(dryRunOption);
        }

        public String applicationId() {
            return options.valueOf(applicationIdOption);
        }

        public boolean hasConfig() {
            return options.has(configOption);
        }


Review comment (bug):
Could you also add a test to verify that the `bootstrap-server` argument is required and that the command fails with a proper error message if it is missing?

Code after:
                .withRequiredArg()
                .ofType(String.class);
            shiftByOption = parser.accepts("shift-by", "Reset offsets shifting current offset by 'n', where 'n' can be positive or negative")
                .withRequiredArg()
                .describedAs("number-of-offsets")
                .ofType(Long.class);
            configOption = parser.accepts("config-file", "(DEPRECATED) Property file containing configs to be passed to admin clients and embedded consumer. "
                    + "This option will be removed in a future version. Use --command-config instead.")
                .withRequiredArg()
                .ofType(String.class)
                .describedAs("file name");
            commandConfigOption = parser.accepts("command-config", "Config properties file to be passed to admin clients and embedded consumer.")
                .withRequiredArg()
                .ofType(String.class)
                .describedAs("file name");
            forceOption = parser.accepts("force", "Force the removal of members of the consumer group (intended to remove stopped members if a long session timeout was used). " +
                "Make sure to shut down all stream applications when this option is specified to avoid unexpected rebalances.");

            dryRunOption = parser.accepts("dry-run", "Display the actions that would be performed without executing the reset commands.");

            try {
                options = parser.parse(args);
                CommandLineUtils.maybePrintHelpOrVersion(this, USAGE);
                CommandLineUtils.checkInvalidArgs(parser, options, toOffsetOption, toDatetimeOption, byDurationOption, toEarliestOption, toLatestOption, fromFileOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, toDatetimeOption, toOffsetOption, byDurationOption, toEarliestOption, toLatestOption, fromFileOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, byDurationOption, toOffsetOption, toDatetimeOption, toEarliestOption, toLatestOption, fromFileOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, toEarliestOption, toOffsetOption, toDatetimeOption, byDurationOption, toLatestOption, fromFileOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, toLatestOption, toOffsetOption, toDatetimeOption, byDurationOption, toEarliestOption, fromFileOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, fromFileOption, toOffsetOption, toDatetimeOption, byDurationOption, toEarliestOption, toLatestOption, shiftByOption);
                CommandLineUtils.checkInvalidArgs(parser, options, shiftByOption, toOffsetOption, toDatetimeOption, byDurationOption, toEarliestOption, toLatestOption, fromFileOption);
                CommandLineUtils.checkInvalidArgs(parser, options, configOption, commandConfigOption);
            } catch (final OptionException e) {
                CommandLineUtils.printUsageAndExit(parser, e.getMessage());
            }
        }

        public boolean hasDryRun() {
            return options.has(dryRunOption);
        }

        public String applicationId() {
            return options.valueOf(applicationIdOption);
        }

        public boolean hasConfig() {
            return options.has(configOption);
        }

        public String config() {
            return options.valueOf(configOption);
        }