Skip to content

Commit 35cd1ff

Browse files
committed
Add support to print method result to the standard output
1 parent 7217526 commit 35cd1ff

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

spring-shell-core/src/main/java/org/springframework/shell/core/command/adapter/MethodInvokerCommandAdapter.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ public ExitStatus doExecute(CommandContext commandContext) throws Exception {
9999
}
100100

101101
// invoke method
102-
methodInvoker.invoke();
103-
commandContext.outputWriter().flush();
104-
102+
Object result = methodInvoker.invoke();
103+
if (result != null) {
104+
// print method result to command output
105+
commandContext.outputWriter().println(result);
106+
commandContext.outputWriter().flush();
107+
}
105108
return ExitStatus.OK;
106109
}
107110

0 commit comments

Comments
 (0)