Closed mfridman closed 6 months ago
I got around this by defining a "global" flag config, e.g.,
func newDirFlag(s *string) ff.FlagConfig {
return ff.FlagConfig{
ShortName: 'd',
LongName: "dir",
Usage: "dir to read migrations from",
NoDefault: true,
Value: ffval.NewValue(s),
}
}
And then just re-using that wherever I needed that specific flag to be available.
fs := ff.NewFlagSet("status")
var dir string
fs.AddFlag(newDirFlag(&dir))
Going to close this, as it appears to be working as intended.
I suppose this is more a question/clarification on the intended behavior of
.GetFlag
and.AddFlag
inv4.0.0-alpha.4
.I passed root flags down to a subcommand, so it has access to
*ff.FlagSet
and then constructed a new flagset, and afaics the only option is to callBut, in some commands I want to selectively add parent flags without duplicating all the bits. So I was expecting something like this to work in the subcommand:
But,
.AddFlag
takes anff.FlagConfig
and.GetFlag
returns anff.Flag
. Curious if this is working as intended and.SetParent
is all-or-nothing, or there could/should be support for selectively inheriting flags?