mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-25 19:49:14 +00:00
Show env option in CLI reference documentation (#6863)
## Summary Closes #6469. <img width="721" alt="image" src="https://github.com/user-attachments/assets/be144e43-e02f-473e-921c-91cf00c3c8d3">
This commit is contained in:
parent
becdd4bdaf
commit
c667588524
2 changed files with 417 additions and 0 deletions
|
@ -245,6 +245,7 @@ fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut
|
|||
if let Some(help) = opt.get_long_help().or_else(|| opt.get_help()) {
|
||||
output.push_str("<dd>");
|
||||
output.push_str(&format!("{}\n", markdown::to_html(&help.to_string())));
|
||||
emit_env_option(opt, output);
|
||||
emit_default_option(opt, output);
|
||||
emit_possible_options(opt, output);
|
||||
output.push_str("</dd>");
|
||||
|
@ -267,6 +268,18 @@ fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut
|
|||
parents.pop();
|
||||
}
|
||||
|
||||
fn emit_env_option(opt: &clap::Arg, output: &mut String) {
|
||||
if opt.is_hide_env_set() {
|
||||
return;
|
||||
}
|
||||
if let Some(env) = opt.get_env() {
|
||||
output.push_str(&markdown::to_html(&format!(
|
||||
"May also be set with the `{}` environment variable.",
|
||||
env.to_string_lossy()
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_default_option(opt: &clap::Arg, output: &mut String) {
|
||||
if opt.is_hide_default_value_set() || !opt.get_num_args().expect("built").takes_values() {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue