2020import java .util .Set ;
2121import org .apache .commons .cli .CommandLine ;
2222import org .apache .commons .cli .Option ;
23+ import org .apache .commons .cli .OptionGroup ;
2324import org .apache .commons .cli .Options ;
2425import org .apache .rocketmq .remoting .RPCHook ;
2526import org .apache .rocketmq .remoting .protocol .EpochEntry ;
@@ -43,15 +44,13 @@ public String commandDesc() {
4344
4445 @ Override
4546 public Options buildCommandlineOptions (Options options ) {
46- Option opt = new Option ("c" , "clusterName" , true , "which cluster" );
47- opt .setRequired (false );
48- options .addOption (opt );
49-
50- opt = new Option ("b" , "brokerName" , true , "which broker to fetch" );
51- opt .setRequired (false );
52- options .addOption (opt );
47+ OptionGroup group = new OptionGroup ();
48+ group .addOption (new Option ("c" , "clusterName" , true , "which cluster" ));
49+ group .addOption (new Option ("b" , "brokerName" , true , "which broker to fetch" ));
50+ group .setRequired (true );
51+ options .addOptionGroup (group );
5352
54- opt = new Option ("i" , "interval" , true , "the interval(second) of get info" );
53+ Option opt = new Option ("i" , "interval" , true , "the interval(second) of get info" );
5554 opt .setRequired (false );
5655 options .addOption (opt );
5756
@@ -68,7 +67,7 @@ public void execute(CommandLine commandLine, Options options,
6867 if (commandLine .hasOption ('i' )) {
6968 String interval = commandLine .getOptionValue ('i' );
7069 int flushSecond = 3 ;
71- if (interval != null && !interval .trim ().equals ( "" )) {
70+ if (interval != null && !interval .trim ().isEmpty ( )) {
7271 flushSecond = Integer .parseInt (interval );
7372 }
7473
0 commit comments