You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by "J. Brebec" <je...@gmail.com> on 2017/09/05 08:54:00 UTC

Gogo scripts and feature:list

Hello,

I want to detect, in a gogo script, if at least N features are installed in Karaf (in order to show an "help" message).

I am trying to do something like :

featuresCount = (features:list -r | grep xxx | wc -l)

however, I can't test featuresCount because it's not a number (wc -l seem to return a string with two values..) How can I make such test in karaf/gogo ?

Regards,
Jérémie


Re: Gogo scripts and feature:list

Posted by "J. Brebec" <je...@gmail.com>.
Thanks ! It's look like black magic, but it works :-)

You have linked a documention from zsh, is there a documentation of the features supported by gogo (jline?)

On 2017-09-05 11:28, Guillaume Nodet <gn...@apache.org> wrote: 
> Try the following:
>   featuresCount = ${${=$(feature:list -r | grep xxx | wc -l)}[1]}
> The ${=...} will turn the output in an array, and ${...[1]} will grab the
> first element.
> See
> http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion
> 
> 2017-09-05 11:04 GMT+02:00 Jean-Baptiste Onofré <jb...@nanthrax.net>:
> 
> > Hi Jérémie,
> >
> > I think you can go directly with the features list:
> >
> > features = $.context features) | grep -i xxx | tac
> > if features.size() ...
> >
> > Regards
> > JB
> >
> > On 09/05/2017 10:54 AM, J. Brebec wrote:
> >
> >> Hello,
> >>
> >> I want to detect, in a gogo script, if at least N features are installed
> >> in Karaf (in order to show an "help" message).
> >>
> >> I am trying to do something like :
> >>
> >> featuresCount = (features:list -r | grep xxx | wc -l)
> >>
> >> however, I can't test featuresCount because it's not a number (wc -l seem
> >> to return a string with two values..) How can I make such test in
> >> karaf/gogo ?
> >>
> >> Regards,
> >> Jérémie
> >>
> >>
> > --
> > Jean-Baptiste Onofré
> > jbonofre@apache.org
> > http://blog.nanthrax.net
> > Talend - http://www.talend.com
> >
> 
> 
> 
> -- 
> ------------------------
> Guillaume Nodet
> 

Re: Gogo scripts and feature:list

Posted by Guillaume Nodet <gn...@apache.org>.
Try the following:
  featuresCount = ${${=$(feature:list -r | grep xxx | wc -l)}[1]}
The ${=...} will turn the output in an array, and ${...[1]} will grab the
first element.
See
http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion

2017-09-05 11:04 GMT+02:00 Jean-Baptiste Onofré <jb...@nanthrax.net>:

> Hi Jérémie,
>
> I think you can go directly with the features list:
>
> features = $.context features) | grep -i xxx | tac
> if features.size() ...
>
> Regards
> JB
>
> On 09/05/2017 10:54 AM, J. Brebec wrote:
>
>> Hello,
>>
>> I want to detect, in a gogo script, if at least N features are installed
>> in Karaf (in order to show an "help" message).
>>
>> I am trying to do something like :
>>
>> featuresCount = (features:list -r | grep xxx | wc -l)
>>
>> however, I can't test featuresCount because it's not a number (wc -l seem
>> to return a string with two values..) How can I make such test in
>> karaf/gogo ?
>>
>> Regards,
>> Jérémie
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>



-- 
------------------------
Guillaume Nodet

Re: Gogo scripts and feature:list

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Jérémie,

I think you can go directly with the features list:

features = $.context features) | grep -i xxx | tac
if features.size() ...

Regards
JB

On 09/05/2017 10:54 AM, J. Brebec wrote:
> Hello,
> 
> I want to detect, in a gogo script, if at least N features are installed in Karaf (in order to show an "help" message).
> 
> I am trying to do something like :
> 
> featuresCount = (features:list -r | grep xxx | wc -l)
> 
> however, I can't test featuresCount because it's not a number (wc -l seem to return a string with two values..) How can I make such test in karaf/gogo ?
> 
> Regards,
> Jérémie
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com