Open muir opened 3 years ago
Agreed. This one is missing. Hope they'll add this.
Does anyone have a temporary workaround?
As a workaround you can use go's flag parser:
fs := pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)
goflag.Func("flagname", "help message for flagname", func(string) error {
fmt.Println("functioning")
return nil
})
fs.AddGoFlagSet(goflag.CommandLine)
fs.Parse([]string{"--flagname", "123"})
As of Go 1.16, base "flag" now has:
Please add for feature parity --
Func()
is probably the best thing about the base "flag" package