Documentation
¶
Index ¶
Constants ¶
const SensitiveAnnotationKey = "sensitive"
SensitiveAnnotationKey is the pflag annotation key used to mark flags whose values contain secrets (cryptographic keys, tokens, etc.) and must not appear in logs or process listings.
Variables ¶
This section is empty.
Functions ¶
func ProcessEmbeddedDocs ¶
Types ¶
type CommandOpts ¶
type CommandOpts func(d *Doc)
func WithHiddenFlags ¶
func WithHiddenFlags(flags ...string) CommandOpts
Hide any global or persisent flags from parent commands on the given command
func WithSubcommands ¶
func WithSubcommands(subCmds ...*Doc) CommandOpts
type Doc ¶
func ProcessDoc ¶
func (*Doc) AddStringFlag ¶ added in v0.37.0
AddStringFlag registers a string flag on cmd from the doc's flag definition, wiring the flag's name, shorthand, default, and description in one call. It reduces the boilerplate of reading each field from GetDocFlag by hand, which is useful for commands that register many flags.
func (*Doc) AddSubcommands ¶
func (*Doc) GetDocFlag ¶
func (*Doc) MarkRequiredFlags ¶ added in v0.37.0
func (d *Doc) MarkRequiredFlags()
MarkRequiredFlags marks every flag the doc metadata declares `required: true` as required on the command, so cobra rejects an invocation that omits it and generated tooling (e.g. the MCP server) can advertise the flag as required.
Unlike MarkSensitiveFlags, flags declared required in the doc but not registered on this command are skipped rather than panicking: the registry sweep visits every doc, including parent/index docs and commands that were never built into the active tree, and flags may be registered on a subcommand or via a shared injector. Call after all flags have been registered.
func (*Doc) MarkSensitiveFlags ¶ added in v0.32.0
func (d *Doc) MarkSensitiveFlags()
MarkSensitiveFlags sets pflag annotations on all flags in the command's FlagSet that are marked sensitive in the doc metadata. Call after all flags have been registered.
type DocFlag ¶
type DocFlag struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Shorthand string `yaml:"shorthand"`
Default string `yaml:"default"`
Enum []string `yaml:"enum"`
Sensitive bool `yaml:"sensitive"`
Required bool `yaml:"required"`
}
func (DocFlag) DefaultAsBool ¶
type Manual ¶
type Manual struct {
Docs map[string]*Doc
En map[string]*Doc
Fr map[string]*Doc
// contains filtered or unexported fields
}
var Docs Manual
func (Manual) GetCommand ¶
func (m Manual) GetCommand(cmd string, opts ...CommandOpts) *Doc
func (Manual) MarkRequiredFlags ¶ added in v0.37.0
func (m Manual) MarkRequiredFlags()
MarkRequiredFlags applies required flag metadata to every registered command.