75
75
import java .util .stream .Collectors ;
76
76
import javax .net .ssl .SSLContext ;
77
77
import javax .net .ssl .TrustManager ;
78
- import org .apache .commons .cli .*;
78
+ import org .apache .commons .cli .CommandLine ;
79
+ import org .apache .commons .cli .CommandLineParser ;
80
+ import org .apache .commons .cli .DefaultParser ;
81
+ import org .apache .commons .cli .MissingArgumentException ;
82
+ import org .apache .commons .cli .Option ;
83
+ import org .apache .commons .cli .Options ;
84
+ import org .apache .commons .cli .ParseException ;
85
+ import org .apache .commons .cli .help .HelpFormatter ;
86
+ import org .apache .commons .cli .help .OptionFormatter ;
79
87
import org .slf4j .Logger ;
80
88
import org .slf4j .LoggerFactory ;
81
89
@@ -970,13 +978,20 @@ private static boolean isPropertyTlsRelated(String propertyName) {
970
978
}
971
979
972
980
private static void usage (Options options ) {
973
- HelpFormatter formatter = new HelpFormatter ();
974
- formatter .printHelp ("<program>" , options );
981
+ HelpFormatter formatter = HelpFormatter .builder ().setShowSince (false ).get ();
982
+ try {
983
+ formatter .printHelp ("perf-test" , "" , options , "" , true );
984
+ } catch (IOException e ) {
985
+ throw new RuntimeException (e );
986
+ }
975
987
}
976
988
977
989
private static void usageWithEnvironmentVariables (Options options ) {
978
- HelpFormatter formatter = new HelpFormatter ();
979
- formatter .setOptPrefix ("" );
990
+ HelpFormatter formatter =
991
+ HelpFormatter .builder ()
992
+ .setShowSince (false )
993
+ .setOptionFormatBuilder (OptionFormatter .builder ().setOptPrefix ("" ))
994
+ .get ();
980
995
Options envOptions = new Options ();
981
996
forEach (
982
997
options ,
@@ -992,10 +1007,17 @@ private static void usageWithEnvironmentVariables(Options options) {
992
1007
option .getDescription ());
993
1008
}
994
1009
});
995
- formatter .printHelp (
996
- "<program>. For multi-value options, separate values "
997
- + "with commas, e.g. VARIABLE_RATE='100:60,1000:10,500:15'" ,
998
- envOptions );
1010
+ try {
1011
+ formatter .printHelp (
1012
+ "perf-test" ,
1013
+ " For multi-value options, separate values "
1014
+ + "with commas, e.g. VARIABLE_RATE='100:60,1000:10,500:15'" ,
1015
+ envOptions ,
1016
+ "" ,
1017
+ true );
1018
+ } catch (IOException e ) {
1019
+ throw new RuntimeException (e );
1020
+ }
999
1021
}
1000
1022
1001
1023
static CommandLineParser getParser () {
0 commit comments