diff --git a/dispatcher.go b/dispatcher.go index 4dfcbde..b60786f 100644 --- a/dispatcher.go +++ b/dispatcher.go @@ -58,6 +58,12 @@ type Example struct { Body string // The example command line or code } +// RequiredFeatureProvider is an interface for commands that require a feature flag to be enabled. +type RequiredFeatureProvider interface { + // RequiredFeature returns the name of the feature flag required for this command. + RequiredFeature() string +} + // OutputFormatter is an interface for commands that can specify their output format type OutputFormatter interface { // OutputFormat returns the output format for this command diff --git a/help_doc.go b/help_doc.go index d6de75b..5d4ed9b 100644 --- a/help_doc.go +++ b/help_doc.go @@ -18,6 +18,7 @@ type HelpDocument struct { type CommandDoc struct { Path string `json:"path"` Usage string `json:"usage"` + RequiredFeature string `json:"requiredFeature,omitempty"` Flags []FlagDoc `json:"flags"` FlagGroups []string `json:"flagGroups"` PositionalArgs []PositionalDoc `json:"positionalArgs,omitempty"` @@ -158,6 +159,9 @@ func (d *Dispatcher) buildCommandDocs(parentPath string) []CommandDoc { }) } } + if rfp, ok := entry.Command.(RequiredFeatureProvider); ok { + cmd.RequiredFeature = rfp.RequiredFeature() + } } }