Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions help_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -158,6 +159,9 @@ func (d *Dispatcher) buildCommandDocs(parentPath string) []CommandDoc {
})
}
}
if rfp, ok := entry.Command.(RequiredFeatureProvider); ok {
cmd.RequiredFeature = rfp.RequiredFeature()
}
}
}

Expand Down