cmdhelp

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2025 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHelpConfig = HelpUIConfig{
	MaxLineWidth:   78,
	IndentSize:     2,
	SectionColor:   pterm.FgCyan,
	CommandColor:   pterm.FgMagenta,
	FlagNameColor:  pterm.FgGreen,
	FlagTypeColor:  pterm.FgBlue,
	DefaultColor:   pterm.FgYellow,
	TextColor:      pterm.FgLightCyan,
	ExampleColor:   pterm.FgMagenta,
	BorderStyle:    *pterm.NewStyle(pterm.FgGray),
	CompactSpacing: true,
}

DefaultHelpConfig: Optimized color scheme with soft cyan for body text Yellow is strictly limited to single default value keywords (no block usage)

Functions

func AddSpacing

func AddSpacing(compact bool)

AddSpacing adds consistent spacing between sections

func ModernHelpFuncPterm

func ModernHelpFuncPterm(cmd *cobra.Command, args []string)

ModernHelpFuncPterm is the main modular help renderer with eye-friendly design Core features: soft cyan block text, yellow limited to single keywords, compact layout

func RenderCommands

func RenderCommands(cmd *cobra.Command, config *HelpUIConfig, formatter *TextFormatter)

RenderCommands renders subcommands (magenta for names, soft cyan for descriptions)

func RenderDescription

func RenderDescription(cmd *cobra.Command, config *HelpUIConfig, formatter *TextFormatter)

RenderDescription renders the long description (soft cyan for block text)

func RenderExamples

func RenderExamples(cmd *cobra.Command, config *HelpUIConfig, formatter *TextFormatter)

RenderExamples renders examples (magenta for commands, soft cyan for comments)

func RenderFlags

func RenderFlags(cmd *cobra.Command, config *HelpUIConfig, formatter *TextFormatter)

RenderFlags renders flags (yellow only for default value keywords)

func RenderFooter

func RenderFooter(cmd *cobra.Command, config *HelpUIConfig)

RenderFooter renders the final help instruction (soft cyan for readability)

func RenderHeader

func RenderHeader(cmd *cobra.Command, config *HelpUIConfig)

RenderHeader renders the main header with clean style (no yellow)

func RenderSectionHeader

func RenderSectionHeader(title string, config *HelpUIConfig)

RenderSectionHeader renders consistent, scannable section headers

func RenderUsage

func RenderUsage(cmd *cobra.Command, config *HelpUIConfig, formatter *TextFormatter)

RenderUsage renders the usage section (no yellow, green for syntax highlight)

Types

type HelpUIConfig

type HelpUIConfig struct {
	MaxLineWidth   int         // Maximum line length for text wrapping
	IndentSize     int         // Base indentation size
	SectionColor   pterm.Color // Color for section headers (highlighted)
	CommandColor   pterm.Color // Color for command names
	FlagNameColor  pterm.Color // Color for flag names
	FlagTypeColor  pterm.Color // Color for flag types
	DefaultColor   pterm.Color // Color for default values (single keyword only)
	TextColor      pterm.Color // Color for body text (soft cyan, eye-friendly)
	ExampleColor   pterm.Color // Color for example commands
	BorderStyle    pterm.Style // Style for section borders (subtle, low visibility)
	CompactSpacing bool        // Enable compact spacing mode to save space
}

-------------------------- Configuration (Core Optimization: White → Soft Cyan for Eye Comfort & Clarity) --------------------------

type TextFormatter

type TextFormatter struct {
	// contains filtered or unexported fields
}

-------------------------- Text Formatter (Modular Wrapping Logic) --------------------------

func NewTextFormatter

func NewTextFormatter(config *HelpUIConfig) *TextFormatter

NewTextFormatter creates a TextFormatter instance with specified config

func (*TextFormatter) WrapText

func (f *TextFormatter) WrapText(text string, baseIndent int) string

WrapText splits long text into properly indented lines Ensures body text (wrapped) uses soft cyan for eye comfort

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL