Console Command Reply

I’m familiar with sending commands to console via Sponge:

Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command);

Is there a way to get the response back from the command? Or to start a ‘Conversation’ with the console to log the output of the command to a variable?

The CommandResult is in fact returned by that very function.

You’re correct in that it does return a CommandResult object. I should’ve been more specific in my original post that I’m looking for something to capture a string reply of a command sent.

For example:
if I send the command “foo” and the plugin responsible for that command replies “bar” I want to be able to catch “bar” into a variable.

From what I’ve looked at https://jd.spongepowered.org/3.1.0/org/spongepowered/api/command/CommandResult.html there’s no method for getting a text based response, which is why I was looking for some kind of conversation service perhaps.

Define “response”. There’s no textual result to a command, there’s just some sendMessage calls. And a conversation API is in the works.

You could override the sendMessage methods in CommandSource and delegate the other methods to the console source.
Here is an example:
https://github.com/simon816/ChatUI/blob/master/src/main/java/com/simon816/chatui/util/ForwardingSource.java

This was 100% what I was looking for and got it working easily. Thanks!!