cmd.Flags().BoolVar(&config.EnableRequestLogs, "grpc-log-requests-enabled", false, "logs API request payloads")
the flag both shows up in the help output and provides its configuration to the underlying command.
When you attach a flag using a flagset, a la:
nfs := cobrautil.NewNamedFlagSets(cmd)
grpcFlagSet := nfs.FlagSet("gRPC")
// Flags for logging
grpcFlagSet.BoolVar(&config.EnableRequestLogs, "grpc-log-requests-enabled", false, "logs API request payloads")
the flag shows up in the help output, but if you attempt to use the flag without having called nfs.AddFlagSets(cmd), the command will complain that the flag isn't known.
Proposal
Is there a way to make the flagset register incrementally or something? Otherwise this seems like something to call out in documentation.
Description
When you attach a flag to a normal command, a la:
the flag both shows up in the help output and provides its configuration to the underlying command.
When you attach a flag using a flagset, a la:
the flag shows up in the help output, but if you attempt to use the flag without having called
nfs.AddFlagSets(cmd)
, the command will complain that the flag isn't known.Proposal
Is there a way to make the flagset register incrementally or something? Otherwise this seems like something to call out in documentation.