Open xenoterracide opened 3 years ago
workaround for the logging problem in case anyone finds this looking for that
@CommandLine.Option(
names = { "--logging.level.com.xenoterracide.brix" }
)
public void setLog( System.Logger.Level log ) {
this.log = log;
}
@xenoterracide Took another look at this issue again after a long time, thank you for your patience!
It would be nice if any spring boot app could pass regular spring boot properties in the same way you would if you weren't using spring boot. I wouldn't expect these to be recorded in help output.
It may be an idea to add a class with these regular spring boot properties/option that can be used as a Mixin for spring boot CLI applications. This class could live in the picocli-spring-boot-starter
module. Do you feel like contributing a pull request for this?
Also, I can't put together how I might have an option for say --log=debug that gets passed essentially like --log.level.whatever.I.want as spring boot.
Your other comment mentions one solution, another solution that generalizes over multiple packages/classes could look like this:
private Map<String, System.Logger.Level> loglevels = new HashMap<>();
@Option(names = { "--logging.level" },
description = {"Sets the log level for a package or class. This option may be specified multiple times.",
"Example usage: --logging.level com.xenoterracide.brix=DEBUG"
})
public void setLog(Map<String, System.Logger.Level> loglevels) {
this.loglevels.putAll(loglevels);
}
lastly, but I haven't really verified this, I don't believe that picocli registers itself as a property source in spring boot, which seems inappropriate. It would seem better to let spring boot actually do the needful in some ways and have people do @ConfigurationProperties classes.
I don't use Spring a lot and have no idea what this is, but I am interested in pull requests either to the documentation to show application developers how to do this, or to the picocli-spring-boot-starter
module if this is something that can/should be done in picocli.
I'm pretty unlikely to do that at this point. The program I was writing to do this with has been replaced with a rust program. For a command line program it is simply too slow to start due to combine performance issues and various libraries including this one. I have yet to really need to add a command line processor to a web service.
It would be nice if any spring boot app could pass regular spring boot properties in the same way you would if you weren't using spring boot. I wouldn't expect these to be recorded in help output.
Also, I can't put together how I might have an option for say
--log=debug
that gets passed essentially like--log.level.whatever.I.want
as spring boot.lastly, but I haven't really verified this, I don't believe that picocli registers itself as a property source in spring boot, which seems inappropriate. It would seem better to let spring boot actually do the needful in some ways and have people do
@ConfigurationProperties
classes.