Skip to content

Commit 0981e94

Browse files
committed
Issue #6041: allow commands with not options such as ‘version’.
1 parent 0807a8b commit 0981e94

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ public static void main(String[] args) {
5555
final Schema schema = schemaMap.get(schemaName);
5656
final String command = CLIHelper.getCommand(schemaName, schema);
5757
final Map<String, Schema> schemaProperties = schema.getProperties();
58-
if(schemaProperties == null || schemaProperties.isEmpty()) {
59-
LOGGER.warn(String.format("there are not options for command '%s'", command));
60-
continue;
61-
}
58+
final Subparser parser = subparsers.addParser(command).help(command);
6259

6360
commandMap.put(command, schema);
6461

65-
final Subparser parser = subparsers.addParser(command).help(command);
66-
62+
if(schemaProperties == null || schemaProperties.isEmpty()) {
63+
LOGGER.debug(String.format("there are not options for command '%s'", command));
64+
continue;
65+
}
6766
for (String propertyName : schemaProperties.keySet()) {
6867
final Schema property = schemaProperties.get(propertyName);
6968
final Map<String, Object> extensions = property.getExtensions();
@@ -114,18 +113,11 @@ public static void main(String[] args) {
114113

115114
BeanUtils.populate(commandObject, optionValueMap);
116115
if(commandObject instanceof Runnable) {
117-
System.out.println("time to run boy...");
118-
((Runnable) commandObject).run();
116+
new Thread(((Runnable) commandObject)).start();
119117
}
120118

121-
} catch (ClassNotFoundException e) {
122-
LOGGER.error(String.format("Could not load class '%s' for command '%s'", className, userInputCommand));
123-
} catch (IllegalAccessException e) {
124-
e.printStackTrace();
125-
} catch (InstantiationException e) {
126-
e.printStackTrace();
127-
} catch (InvocationTargetException e) {
128-
e.printStackTrace();
119+
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | InvocationTargetException ex) {
120+
LOGGER.error(String.format("Could not load class '%s' for command '%s'", className, userInputCommand), ex);
129121
}
130122
}
131123
}

0 commit comments

Comments
 (0)