7575import java .util .stream .Collectors ;
7676import javax .net .ssl .SSLContext ;
7777import 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 ;
7987import org .slf4j .Logger ;
8088import org .slf4j .LoggerFactory ;
8189
@@ -970,13 +978,20 @@ private static boolean isPropertyTlsRelated(String propertyName) {
970978 }
971979
972980 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+ }
975987 }
976988
977989 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 ();
980995 Options envOptions = new Options ();
981996 forEach (
982997 options ,
@@ -992,10 +1007,17 @@ private static void usageWithEnvironmentVariables(Options options) {
9921007 option .getDescription ());
9931008 }
9941009 });
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+ }
9991021 }
10001022
10011023 static CommandLineParser getParser () {
0 commit comments