micronaut-projects / micronaut-picocli

Integration between Micronaut and PicoCLI
Apache License 2.0
21 stars 12 forks source link

Feature: Add to have a configuration file PropertySource as command options #21

Open tchiotludo opened 4 years ago

tchiotludo commented 4 years ago

It will be very nice to have the possibility to declare a new option on picocli micronaut that will be used a new PropertySource (maybe with Custom Type Converters), like that :

public class MyCliAppCommand implements Runnable { 
    @Option(names = {"-c", "--config"}, description = "Path to configuration file") 
    PropertySourceFile config;
}

The file will be added as a PropertySource and will override the default one. I think it's a standard behavior of a some cli app to have a configuration file option in order to avoid the lot of --optA A --optB B --optC C

As I see, for now, there is no workaround to allow this kind of options (or need to parse the args like on https://github.com/micronaut-projects/micronaut-picocli/issues/20). And as i see the PropertySource can't be added after the init of ApplicationContext (no way to add some configuration during runtime).

edward3h commented 2 years ago

I have a similar request - it would be nice to override or add an environment with an option. Again there's a problem with the order of initializing the context!

e.g. I could run

mycmd --environment production ...