Skip to content

Commit 6a8dbf6

Browse files
adjust cli help option
1 parent 84c0445 commit 6a8dbf6

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

asyncapi-importer-cli/src/main/java/com/solace/ep/asyncapi/cli/AsyncApiImport.java

+17-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public static void main(String[] args)
7474

7575
// Parse out options
7676
try {
77-
if (checkForHelpOption(options, args)) {
77+
if (checkForHelpOption(args)) {
78+
displayHelp(options);
7879
return;
7980
}
8081
CommandLineParser cliParser = new DefaultParser();
@@ -124,13 +125,23 @@ public static void main(String[] args)
124125
}
125126
}
126127

127-
private static boolean checkForHelpOption( final Options options, final String[] args ) throws ParseException
128+
private static boolean checkForHelpOption( String[] args )
128129
{
130+
Option helpOption = new Option("h", "help", false, "Help Option");
131+
Options options = new Options();
132+
options.addOption(helpOption);
133+
129134
CommandLineParser cliParser = new DefaultParser();
130-
CommandLine commandLine = cliParser.parse(options, args);
131-
boolean hasHelpOption = commandLine.hasOption("h");
132-
if (hasHelpOption) {
133-
displayHelp(options);
135+
boolean hasHelpOption = false;
136+
137+
try {
138+
CommandLine commandLine = cliParser.parse(options, args, false);
139+
hasHelpOption = commandLine.hasOption("h");
140+
// if (hasHelpOption) {
141+
// displayHelp(options);
142+
// }
143+
} catch (ParseException parseException) {
144+
return false;
134145
}
135146
return hasHelpOption;
136147
}

0 commit comments

Comments
 (0)