Ok, but the formatter doesn't always do what I want.

Right now I return an array of objects and I want the Converter.INSPECT
level of detail when printing each item in the array.
The formatter uses Converter.INSPECT level for the array, but
Converter.PART or Converter.LINE for each item.
So what should I do:
- Add another command to inspect one item?
- Define my own format for that exact array?
- ..?

On Fri, Jan 18, 2019 at 5:23 PM Raymond Auge <raymond.a...@liferay.com>
wrote:

> return!
>
> When you print you go around the formatters engine and you cannot pipe as
> nicely.
>
> 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 <rinsv...@gmail.com> 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é* <http://www.liferay.com/web/raymond.auge/profile>
>  (@rotty3000)
> Senior Software Architect *Liferay, Inc.* <http://www.liferay.com>
>  (@Liferay)
> Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org>
> (@OSGiAlliance)
>

Reply via email to