Open dbrgn opened 1 year ago
Note: This comment by @epage might be related / an alternative API to the suggested .visible_alias
method:
Kind of like how clap switched from possible values being a
&str
toPossibleValue
, I wonder if we should have anAlias<T>
which has ahide
method on it.
I broke that comment out into #4421. I think I'd prefer not going that route for PossibleValue until we do it for everything as it'd be weird to have such a divergent API.
The big question for me for this is how visible aliases for possible values should be rendered. In the short help, it feels weird to redundantly list options that map back to the same thing and would get weird nesting expressions into each other. With long help, we could have an [aliases: ...]
after the item, I guess.
I thought of two solutions for the short help:
[possible values: foo-option (foo, f) , bar-option (b), no-alias-option]
We can make printing aliases in short description optional be adding a boolean or a flag for the function. Something like:
// Boolean option
pub fn visible_alias(mut self, name: impl IntoResettable<Str>, short-help: bool) -> ...
// Flag option
pub fn visible_alias(mut self, name: impl IntoResettable<Str>, flags: AliasFlags) -> ...
bitflags! {
pub struct AliasFlags: u32 {
const ShortHelp = 0b00000001;
...
}
}
We can make printing aliases in short description optional be adding a boolean or a flag for the function.
We're trying to keep minimum the configuration we provide, focusing on a consistent, quality out of box experience.
Please complete the following tasks
Clap Version
4.0.18
Describe your use case
Tealdeer has a parameter
-p, --platform <PLATFORM>
to select the platform. For historic reasons, this list must include "osx", but should also include the alias "macos". This alias should not be hidden, but should be visible.With Clap 3, this was implemented using
FromStr
:With Clap 4, I tried to migrate to
EnumValueParser
:This works, but the alias is not visible in help output or error messages.
Describe the solution you'd like
Since
Command
has both.alias(...)
and.visible_alias(...)
, would this be possible forPossibleValue
as well?Alternatives, if applicable
No response
Additional Context
No response