Documentation
¶
Overview ¶
Package topics provides a pluggable, topic-based help system for Cobra CLI applications. It extends the default Cobra help functionality to support arbitrary help topics loaded from files, making CLIs self-documenting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
Initialize sets up the topic-based help system with default extensions
Types ¶
type GlamourRenderer ¶ added in v0.1.1
type GlamourRenderer struct {
Style string // Style name: "dark", "light", "notty", "auto", or path to custom style
Width int // Terminal width (0 = auto-detect)
}
GlamourRenderer uses the glamour library for rich markdown rendering
func NewGlamourRenderer ¶ added in v0.1.1
func NewGlamourRenderer() *GlamourRenderer
NewGlamourRenderer creates a markdown renderer using glamour with auto-detection
type Options ¶ added in v0.1.1
type Options struct {
// Extensions is the list of file extensions to consider as topics
// Defaults to [".txt", ".md"] if not specified
Extensions []string
// Renderer for formatting topic content (optional)
// Defaults to PlainRenderer if not specified
Renderer Renderer
}
Options configures the TopicManager
type PlainRenderer ¶ added in v0.1.1
type PlainRenderer struct{}
PlainRenderer is the default renderer that returns content as-is
type Renderer ¶ added in v0.1.1
type Renderer interface {
// Render takes raw content and returns formatted content for terminal display
Render(content string, format string) string
}
Renderer defines the interface for rendering topic content
type TopicManager ¶
type TopicManager struct {
// contains filtered or unexported fields
}
TopicManager manages help topics for a Cobra application
func New ¶
func New(topicsDir string) *TopicManager
New creates a new TopicManager with default extensions
func NewWithOptions ¶ added in v0.1.1
func NewWithOptions(topicsDir string, opts Options) *TopicManager
NewWithOptions creates a new TopicManager with custom options
func (*TopicManager) DisplayTopicsList ¶ added in v0.1.1
func (tm *TopicManager) DisplayTopicsList()
DisplayTopicsList prints the list of available topics
func (*TopicManager) GetTopic ¶
func (tm *TopicManager) GetTopic(name string) (*Topic, bool)
GetTopic retrieves a topic by name
func (*TopicManager) ListTopics ¶
func (tm *TopicManager) ListTopics() []string
ListTopics returns all available topic names