-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
questionFurther information is requestedFurther information is requested
Description
Re the discussion here, it's common to want multiple envs/flags to configure the same underlying option value esp. when refactoring the command line interface.
@mafredri proposes the concept of an OptionAlias that embeds within each Option like so:
type OptionAlias struct {
Flag string `json:"flag,omitempty"`
FlagShorthand string `json:"flag_shorthand,omitempty"`
Env string `json:"env,omitempty"`
Deprecated string `json:"deprecated,omitempty"`
}
// Option is a configuration option for a CLI application.
type Option struct {
Aliases []OptionAlias `json:"aliases,omitempty"`
// ...
}
// Usage:
{
// ...
Env: "CODER_FOOBAR",
Alias: []serpent.OptionAlias{
{Env: "FOOBAR", Deprecated: "Use CODER_FOOBAR instead."},
},
},I think the extra level of nesting on all options is unjustified when in the vast majority of options there is only one "alias".
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested