Add the Ability to Display Visible Aliases for PossibleValues
naftulikay opened this issue · comments
Please complete the following tasks
- I have searched the discussions
- I have searched the open and rejected issues
Clap Version
master
Describe your use case
Consider the following use-case:
use clap::{Parser, ValueEnum};
#[derive(Debug, Clone, Parser)]
pub struct Args {
/// The environment to execute in
#[arg(short = 'e', long = "env")]
pub env: Env,
}
#[derive(Debug, Clone, ValueEnum)]
pub enum Env {
/// The development environment
#[value(aliases = ["dev", "d"])]
Development,
/// The staging environment
Staging,
/// The production environment
#[value(aliases = ["prod"])]
Production,
}
In this case, #[value(aliases = ["prod"])
adds an alias, but this alias is hidden, regardless of whether hide
is set or not. The existing API allows these aliases but does not display them in -h
or --help
output.
Describe the solution you'd like
To this end, I propose that we add a visible_alias
and visible_aliases
function to PossibleValue to allow users to add visible aliases which will show up in help text. PR is incoming.
Alternatives, if applicable
This seems to be the most direct way of doing this.
Additional Context
No response