I've an application with subcommands like that :
@Command(name = "topcmd", subcommands = {SubCmd1.class, SubCmd2.class})
class TopCommand implements Callable<Object> {
public static void main(String[] args) {
PicocliRunner.execute(TopCommand.class, args);
}
//...
}
I want to be able to add some PropertySource (custom configuration) for only 1 subcommands (for example SubCmd2.class will add a configuration "myapp.myconfig": "foo" only when running te command from SubCmd2).
I don't think it's possible for now ?
The only solution I see is to used this signature when init Picocli :
public static <C extends Callable<T>, T> T call(Class<C> cls, ApplicationContext ctx, String... args) {
instead of simple on PicocliRunner.call(App.class, args); in order to provide some configuration directly in ApplicationContext but this will need to parse the String[] args to determine the current command, that is not really easy and can be buggy since it's not parse by picocli.
I've an application with subcommands like that :
I want to be able to add some PropertySource (custom configuration) for only 1 subcommands (for example
SubCmd2.classwill add a configuration"myapp.myconfig": "foo"only when running te command from SubCmd2).I don't think it's possible for now ?
The only solution I see is to used this signature when init Picocli :
instead of simple on
PicocliRunner.call(App.class, args);in order to provide some configuration directly inApplicationContextbut this will need to parse theString[] argsto determine the current command, that is not really easy and can be buggy since it's not parse by picocli.