scaphandre icon indicating copy to clipboard operation
scaphandre copied to clipboard

Enable scaphandre to read its configuration from a file

Open bpetit opened this issue 3 years ago • 5 comments

Problem

All the configuration has to be passed as flags in the command line today.

Solution

I'd like to be able to write the behaviour I want Scaphandre to adopt in a file, give it this file's path to read (with --config for example).

bpetit avatar Dec 17 '21 08:12 bpetit

Hi, I believe getting config from environment variables may be a related topic.

As far as i can read rust (not much yet ;-)) I understand that scaphandre uses clap (https://docs.rs/clap/2.33.3/clap/) to parse it's command line arguments.

Do you think that a integrating a library like clap_conf (https://lib.rs/crates/clap_conf) could help unifying cli args, env vars and config file ?

demeringo avatar Jan 05 '22 16:01 demeringo

Hi ! Absolutely. Thanks for sharing this, this library seems to be worth a shot !

bpetit avatar Jan 06 '22 17:01 bpetit

Hello, coming with clap 4.0 (coming in #234), we can add an env directive to get value from an env variable. https://docs.rs/clap/4.0.19/clap/builder/struct.Arg.html#method.env It seems pretty simple to add, not intrusive and avoids a new dependency. Used with a dotenv file it could be a friendly alternative.

uggla avatar Nov 07 '22 00:11 uggla

Hi! Clap can be "augmented" with argfile in order to load arguments from a file, it seems to do what you're looking for.

TheElectronWill avatar Feb 07 '23 10:02 TheElectronWill

Thanks to @TheElectronWill work on clap, it should be done for 1.1 release

bpetit avatar Jun 07 '23 13:06 bpetit