You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Васил Зорев <va...@gmail.com> on 2021/06/08 16:42:08 UTC

Best practice for multi-argument karaf commands

Hello,

I am looking into the possibility of a Karaf command which can take a
bigger number of arguments (probably 10 or more).

The closest use case I can give is a map of key-value pairs (or
properties?). Something like ID1=val1, ID2=val2 etc. where each ID is a
String value. The main argument for a map (vs List) is that the IDs
represent different entity types, so I cannot treat them the same way.

I saw in org.apache.karaf.shell.support.converter.DefaultConverter there is
a possibility to convert maps. However in
the org.apache.karaf.shell.api.action.Argument
and org.apache.karaf.shell.api.action.Option API, the multiValued attribute
says it expects a list.

Can this be done with a org.apache.karaf.shell.api.console.Parser ?

Do you think it is a good idea at all in the context of command-line
operations or would you recommend another approach ?

Thank you,
Regards,
Vassil

Re: Best practice for multi-argument karaf commands

Posted by Васил Зорев <va...@gmail.com>.
Thanks, I think this fits the use case as well :) and is probably more
structured than the system properties.

On Thu, 10 Jun 2021, 12:47 Sascha Vogt, <sa...@gmail.com> wrote:

> Hi Vassil,
>
>
> Am 08.06.2021 um 20:10 schrieb Васил Зорев:
> >         I am looking into the possibility of a Karaf command which can
> >         take a bigger number of arguments (probably 10 or more).
>
> Well, another option is to pass some sort of config or arguments file
> with structured data (JSON, YAML, XML) and give that in the command
> (--config <path-to-file>)
>
>
> Greetings
> -Sascha-
>

Re: Best practice for multi-argument karaf commands

Posted by Sascha Vogt <sa...@gmail.com>.
Hi Vassil,


Am 08.06.2021 um 20:10 schrieb Васил Зорев:
>         I am looking into the possibility of a Karaf command which can
>         take a bigger number of arguments (probably 10 or more).

Well, another option is to pass some sort of config or arguments file
with structured data (JSON, YAML, XML) and give that in the command
(--config <path-to-file>)


Greetings
-Sascha-

Re: Best practice for multi-argument karaf commands

Posted by Васил Зорев <va...@gmail.com>.
The point is there are multiple commands and one command produces these IDs
as a result of its execution which are then needed by the other commands
for their own execution. Honestly I'm leaning more toward system properties
as this is a test environment anyway, doesn't have to be perfectly
designed...

Still, if you have recommendations, please let me know.

На вт, 8.06.2021 г. в 20:26 ч. Васил Зорев <va...@gmail.com>
написа:

> btw doesn't have to be arguments specifically. Can be options as well,
> similar to the git style: git -c name1=value1 -c name2=value2 etc.
>
> На вт, 8.06.2021 г. в 19:42 ч. Васил Зорев <va...@gmail.com>
> написа:
>
>> Hello,
>>
>> I am looking into the possibility of a Karaf command which can take a
>> bigger number of arguments (probably 10 or more).
>>
>> The closest use case I can give is a map of key-value pairs (or
>> properties?). Something like ID1=val1, ID2=val2 etc. where each ID is a
>> String value. The main argument for a map (vs List) is that the IDs
>> represent different entity types, so I cannot treat them the same way.
>>
>> I saw in org.apache.karaf.shell.support.converter.DefaultConverter there
>> is a possibility to convert maps. However in
>> the org.apache.karaf.shell.api.action.Argument
>> and org.apache.karaf.shell.api.action.Option API, the multiValued attribute
>> says it expects a list.
>>
>> Can this be done with a org.apache.karaf.shell.api.console.Parser ?
>>
>> Do you think it is a good idea at all in the context of command-line
>> operations or would you recommend another approach ?
>>
>> Thank you,
>> Regards,
>> Vassil
>>
>

Re: Best practice for multi-argument karaf commands

Posted by Васил Зорев <va...@gmail.com>.
btw doesn't have to be arguments specifically. Can be options as well,
similar to the git style: git -c name1=value1 -c name2=value2 etc.

На вт, 8.06.2021 г. в 19:42 ч. Васил Зорев <va...@gmail.com>
написа:

> Hello,
>
> I am looking into the possibility of a Karaf command which can take a
> bigger number of arguments (probably 10 or more).
>
> The closest use case I can give is a map of key-value pairs (or
> properties?). Something like ID1=val1, ID2=val2 etc. where each ID is a
> String value. The main argument for a map (vs List) is that the IDs
> represent different entity types, so I cannot treat them the same way.
>
> I saw in org.apache.karaf.shell.support.converter.DefaultConverter there
> is a possibility to convert maps. However in
> the org.apache.karaf.shell.api.action.Argument
> and org.apache.karaf.shell.api.action.Option API, the multiValued attribute
> says it expects a list.
>
> Can this be done with a org.apache.karaf.shell.api.console.Parser ?
>
> Do you think it is a good idea at all in the context of command-line
> operations or would you recommend another approach ?
>
> Thank you,
> Regards,
> Vassil
>