You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a little CLI app that I also execute as a CronJob in Kubernetes. For this I used Helm to set up templates and "values files" which in turn generate the required Kubernetes manifests.
The little Clap CLI I've cfeated is called like this:
./sync-data --store-source-cache
Now when I set up the Kubernetes CronJob values file I prefer to do it the Twelve-Factor App way, specifying the options and arguments as environment variables instead (which might differ between staging/production etc).
It works well for arguments and parameters. But for flags it feels a bit awkward, having to comment out the environment variable from the values.yaml files (there's one with base settings, one for prod env, one for staging env).
As you can see I have to comment out LOAD_SOURCE_CACHE: "" in the base and staging values files. (The base and the prod/staging file are merged together)
Example main.rs which shows current behavior:
use clap::Clap;#[derive(Clap)]structOpts{#[clap(long, env, takes_value = false)]load_source_cache:bool,}fnmain(){let opts:Opts = Opts::parse();println!("Value for load_source_cache: {}", opts.load_source_cache);}
Example output with 3.0.0-beta.2:
❯ cargo run -q
load_source_cache: false
❯ LOAD_SOURCE_CACHE=1 cargo run -q
load_source_cache: true
❯ LOAD_SOURCE_CACHE=0 cargo run -q
load_source_cache: true
❯ LOAD_SOURCE_CACHE=false cargo run -q
load_source_cache: true
❯ LOAD_SOURCE_CACHE=true cargo run -q
load_source_cache: true
Describe the solution you'd like
What I would like to be able to specify in the files instead is:
--flag + --flag=bool (bool is determined by strtobool) in CLI, FLAG=bool in env
The pseudo-flag pattern (remains unchanged)
I'm aware of the fact that for CLI flags there is a separate issue #1649, so first I'd like to focus on the possibility of using the strtobool approach just for env args.
Please complete the following tasks
Describe your use case
I have a little CLI app that I also execute as a CronJob in Kubernetes. For this I used Helm to set up templates and "values files" which in turn generate the required Kubernetes manifests.
The little Clap CLI I've cfeated is called like this:
Now when I set up the Kubernetes CronJob values file I prefer to do it the Twelve-Factor App way, specifying the options and arguments as environment variables instead (which might differ between staging/production etc).
It works well for arguments and parameters. But for flags it feels a bit awkward, having to comment out the environment variable from the
values.yaml
files (there's one with base settings, one for prod env, one for staging env).So currently it looks like this:
As you can see I have to comment out
LOAD_SOURCE_CACHE: ""
in the base and staging values files. (The base and the prod/staging file are merged together)Example
main.rs
which shows current behavior:Example output with 3.0.0-beta.2:
Describe the solution you'd like
What I would like to be able to specify in the files instead is:
I.e. the value set for the "flag env var" should be specified with:
Any other value would be ignored (maybe empty value would mean
false
).Alternatives, if applicable
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: