Triggering/Linking commands?

7 views
Skip to first unread message

Bartosz Baranowski

unread,
Sep 23, 2024, 3:04:51 AM9/23/24
to picocli
Hello

Quick search nor documentation( so far) revealed way to achieve above. 
So, bottom line - is there either a design practice or way to trigger another command conditionally from other command?


picocli

unread,
Sep 23, 2024, 3:55:02 AM9/23/24
to picocli
Not sure that I follow your intention...
The end user specifies the command to execute and options to fine-tune this execution.

When you say, "trigger a command (A) conditionally from another command (B)", it sounds to me that your application has some logic that the user may either invoke directly by explicitly invoking command A, or indirectly, by invoking command B, which may invoke command A under the hood. Is my understanding correct?

While there is nothing that prevents you from doing this, picocli also does not offer special support for this.
You will just have to code your commands using public classes and methods so that command B can call the logic in command A.

Does that answer your question?

Kind regards,
Remko

Bartosz Baranowski

unread,
Sep 23, 2024, 4:30:52 AM9/23/24
to picocli
Yes, more or less you got it right. Lets say in my case CommandA builds library and CommandB start JDK with said library as runtime. CommandB has switch/parameter( for some reason) which essentially  delete said library.
So CommandB --clean_slate should ideally call CommandA before it kickstarts JDK. But given your answer and my findings so far thats no possible.

Id assume that in such case public classes/methods from CommandA should be arranged in a way so they contain pure business logic and dont depend on picocli features, right?
Reply all
Reply to author
Forward
0 new messages