From 5c56c1f093da0800120d49c3f6bcfa85c7e12ecb Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Tue, 17 Feb 2026 12:54:25 -0800 Subject: [PATCH] Add ability to tag a command with a feature flag Used to emit docs for the commands --- dispatcher.go | 6 ++++++ help_doc.go | 4 ++++ 2 files changed, 10 insertions(+) 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() + } } }