help

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package help renders command help, usage, version, and completion instructions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(cmdChain []*spec.Command) string

Format returns the complete, formatted help screen for the given command chain.

func FormatWith

func FormatWith(cmdChain []*spec.Command, opts Options) string

FormatWith returns the complete, formatted help screen for the given command chain, delegating feature-specific sections to the optional renderers in opts. The completion subsystem is reachable only through renderers installed by the completion-enabled engine path.

func Hint

func Hint(cmdChain []*spec.Command) string

Hint returns the short hint pointing the user to --help.

func RenderCompletionFooter

func RenderCompletionFooter(cmdChain []*spec.Command, useFlag bool, detect func() (completion.CurrentShell, bool)) string

RenderCompletionFooter renders the generic completion screen footer: the supported-shells list plus the dynamically generated current-shell enable hints. It is the completion-enabled implementation behind Options.CompletionFooter; detect resolves the caller's shell and is injectable for deterministic tests.

func RenderCompletionInstructions

func RenderCompletionInstructions(shell string, useFlag bool, rootName string) string

RenderCompletionInstructions renders the enable instructions body of a completion screen pinned to one shell. It is the completion-enabled implementation behind Options.CompletionInstructions.

func RenderFeatures

func RenderFeatures(root *spec.Command) string

RenderFeatures renders the automatic Features section of the root help screen: one aligned row per feature toggle, in declaration order, carrying the feature's help text followed by its declared stage, integer levels, and default. GA and deprecated features are omitted — they are no longer experimental — and the section renders nothing when no feature remains. It is the feature-enabled implementation behind Options.FeaturesSection.

func Usage

func Usage(cmdChain []*spec.Command) string

Usage returns the standard 1-2 line usage syntax for the given command chain.

func VersionDetailed

func VersionDetailed(appName string, userVersion string) string

VersionDetailed formats the docker-style multi-line version block (for the `version` subcommand), with the full commit hash and commit timestamp.

func VersionJSON

func VersionJSON(userVersion string) string

VersionJSON formats the flat machine-readable version object (for `version --json`). Every key is always present; unknown values are empty strings.

func VersionSummary

func VersionSummary(appName string, userVersion string) string

VersionSummary formats the single-line version string (for --version): "<app> has version <version> built with <go>" plus " from <commit>" and " on <commit time>" when the version string does not already embed them.

Types

type BuildInfoData

type BuildInfoData struct {
	Version    string
	Commit     string
	CommitDate string
	Dirty      bool
	GoVersion  string
	OS         string
	Arch       string
}

BuildInfoData holds build-time metadata extracted from Go runtime and debug information.

func GetBuildInfo

func GetBuildInfo(userVersion string) BuildInfoData

GetBuildInfo extracts build metadata from runtime/debug.ReadBuildInfo().

type Options

type Options struct {
	// CompletionInstructions renders the per-shell enable instructions of a
	// completion command pinned to one shell (e.g. `--completion zsh --help`).
	CompletionInstructions func(shell string, useFlag bool, rootName string) string
	// CompletionFooter renders the supported-shells footer of the generic
	// completion screen.
	CompletionFooter func(cmdChain []*spec.Command, useFlag bool) string
	// FeaturesSection renders the automatic Features section of the root help
	// screen. It is reached exclusively through the feature-enabled engine
	// path, so applications that never enable features keep the feature help
	// payload unreferenced.
	FeaturesSection func(root *spec.Command) string
}

Options carries optional feature renderers for feature-specific help screens. The zero value renders every screen without completion-specific sections: the completion subsystem is reachable only through renderers installed by the completion-enabled engine path.

Jump to

Keyboard shortcuts

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