When you print you go around the formatters engine and you cannot pipe as

The shell API is designed for returning results from command methods. These
can be complex objects which are much better for piping between commands
than strings on sysout. The formatter engine only kicks in when actually
printing out the result and so you can get nice output while having really
great piping.

Furthermore, when you force the use of ThreadIO to manage the sys.out/err
you introduce complex threading issues that make things like calling the
command engine from other places (believe me when I say it can be useful)
very, very painful.

My suggestion is to avoid using sys.out/err whenever possible.

- Ray

On Fri, Jan 18, 2019 at 9:53 AM Todor Boev <> wrote:

> Hi,
> When implementing a Gogo shell command are there any rules of thumb on
> whether I should return a result from the command method or print it on
> System.out? Possibly using the CommandSession to format it first.
> What bothers me is that AFAIK the automatic printing of return values from
> command methods may be turned off.
> Regards
> Todor

*Raymond Augé* <>
Senior Software Architect *Liferay, Inc.* <>
Board Member & EEG Co-Chair, OSGi Alliance <> (@OSGiAlliance)

Reply via email to