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 want to offer the ability to quickly generate a placeholder .env file for developers working on my projects. This information is contained with the App struct via the name / help text / environment variable name. However, I cannot access the environment variable or default value.
dotenv is a crate that allows specifying an .env file containing environment variables in a file. This allows developers to have a semi-persistent way to store and document environment variables needed to run an application.
Clap allows specifying environment variables as fallback sources for command line options. This includes the environment variable names, documentation about them, default values, possible values, etc.
Describe the solution you'd like
I want to reuse the definitions we've already given to Clap to generate a skeleton .env file:
use clap::{IntoApp,Clap};#[derive(Clap)]structConfig{#[clap(long, default_value = "world", env = "NAME")]/// The name to usename:String,}fnmain(){let app: clap::App = Config::into_app();for arg in app.get_arguments(){println!("# {}", arg.get_about().unwrap_or(""));println!("# {}", arg.get_possible_values().unwrap_or(&[]).join(", "));println!("# {} = {}", arg.get_env(), arg.get_default_value());// Does not exist ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^}}
This will generate the output
# The name to use
#
# NAME = world
A developer starting on the project can direct that output to a .env file and edit it as needed.
Alternatives, if applicable
No response
Additional Context
Ideally in a stable release of Clap, but in a beta release would be cool too!
The text was updated successfully, but these errors were encountered:
Please complete the following tasks
Describe your use case
I want to offer the ability to quickly generate a placeholder
.env
file for developers working on my projects. This information is contained with theApp
struct via the name / help text / environment variable name. However, I cannot access the environment variable or default value.dotenv is a crate that allows specifying an
.env
file containing environment variables in a file. This allows developers to have a semi-persistent way to store and document environment variables needed to run an application.Clap allows specifying environment variables as fallback sources for command line options. This includes the environment variable names, documentation about them, default values, possible values, etc.
Describe the solution you'd like
I want to reuse the definitions we've already given to Clap to generate a skeleton
.env
file:This will generate the output
A developer starting on the project can direct that output to a
.env
file and edit it as needed.Alternatives, if applicable
No response
Additional Context
Ideally in a stable release of Clap, but in a beta release would be cool too!
The text was updated successfully, but these errors were encountered: