--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/83fd5231-3126-4fa5-81ca-1e3fc9be24e1%40googlegroups.com.
//import io.quarkus.picocli.QuarkusPicocliFactory;
import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.context.ManagedExecutor;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import java.util.List;
import java.util.concurrent.Callable;
@QuarkusMain
@ApplicationScoped
@Command(name = "configdemo", mixinStandardHelpOptions = true)
public class ConfigurationExample implements Callable<Integer>, QuarkusApplication {
//@Inject
//QuarkusPicocliFactory factory; // requires the picocli extension, but not needed here
@Option(names = {"-t", "--topic"}, description = "Specifies a Kafka Topic to connect to")
@ConfigBinding("quarkus.kafka-streams.topics")
List<String> topics;
@Override
public Integer call() throws Exception {
System.out.printf("Now do something with topics %s...%n", topics);
return 0;
}
@Override
public int run(String... args) throws Exception {
//int exitCode = new CommandLine(this, factory).execute(args); // requires the picocli extension (but not needed here)
int exitCode = new CommandLine(this).execute(args);
System.out.printf("%s exiting with %d...%n", getClass().getName(), exitCode);
return exitCode;
}
public static void main(String[] args) {
System.setProperty("quarkus.banner.enabled", "false");
Quarkus.run(ConfigurationExample.class, args);
}
}
To unsubscribe from this group and stop receiving emails from it, send an email to quark...@googlegroups.com.
Hi Stuart,I believe you are referring to this thread: https://github.com/quarkusio/quarkus/issues/9058Yes, this should be possible.The only question I have is when the `@ConfigBinding` annotation would be evaluated:
- Quarkus first does some initialization, then invokes the QuarkusApplication::run method, which starts picocli command line parsing.
- The canonical way to use picocli is to construct a CommandLine instance with your command and call execute on it with the command line args. Picocli will then populate `@Option` and `@Parameters`-annotated fields and invoke the `run` or `call` method of your command. (There is an alternative parseArgs method that can be used instead of execute that only populates the annotated fields and then returns.)
- Once the `run` or `call` method is invoked (or parseArgs returns), the `@Option` and `@Parameters`-annotated fields have been initialized, so from this point on, that field can be used as a source of configuration values.
Does this match your expectations?
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/24a274c0-2ef2-43d4-aa3b-b684c42b2d23%40googlegroups.com.
On Thu, 7 May 2020 at 11:25, Remko Popma <remko...@gmail.com> wrote:Hi Stuart,I believe you are referring to this thread: https://github.com/quarkusio/quarkus/issues/9058Yes, this should be possible.The only question I have is when the `@ConfigBinding` annotation would be evaluated:
- Quarkus first does some initialization, then invokes the QuarkusApplication::run method, which starts picocli command line parsing.
- The canonical way to use picocli is to construct a CommandLine instance with your command and call execute on it with the command line args. Picocli will then populate `@Option` and `@Parameters`-annotated fields and invoke the `run` or `call` method of your command. (There is an alternative parseArgs method that can be used instead of execute that only populates the annotated fields and then returns.)
- Once the `run` or `call` method is invoked (or parseArgs returns), the `@Option` and `@Parameters`-annotated fields have been initialized, so from this point on, that field can be used as a source of configuration values.
Does this match your expectations?Mostly, I think we will want to run parseArgs early in the lifecycle, to make sure that everything is initialized and available. We may have applications that are not really picocli apps (as they don't have a Command, they are just running a web server), but it still wants to parse arguments, print usage info etc.It sounds like this still should be possible just by manually calling parseArgs ?
Stuart
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/24a274c0-2ef2-43d4-aa3b-b684c42b2d23%40googlegroups.com.
Note that strictly speaking these use cases do not require the picocli extension that is the topic of this thread; we can progress the configuration use case separate from the picocli extension.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/4be3b3cc-858f-498b-9577-d9f25842f2b5%40googlegroups.com.
RUNTIME_INIT.To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/4be3b3cc-858f-498b-9577-d9f25842f2b5%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/ce58b90c-4aec-4d52-94fa-a6e739e31733%40googlegroups.com.
Does something like this already exist in the picocli extension? or is it planned?After working with picocli and quarkus now for some time I notice that i currently have to decide between a command-parameter/option and a configproperty; but i would prefer to have some mix sometimes. E.g. for testing and different profiles i would like to have the option to set some parameters in the application.properties. So, it defines a default. Only if a parameter is set when running the cli app, it should be overwritten.Does this make sense? Or is it maybe already possible today in some way?