Documentation
¶
Overview ¶
Package help renders command help, usage, version, and completion instructions.
Index ¶
- func Format(cmdChain []*spec.Command) string
- func FormatWith(cmdChain []*spec.Command, opts Options) string
- func Hint(cmdChain []*spec.Command) string
- func RenderCompletionFooter(cmdChain []*spec.Command, useFlag bool, ...) string
- func RenderCompletionInstructions(shell string, useFlag bool, rootName string) string
- func RenderFeatures(root *spec.Command, width int) string
- func Usage(cmdChain []*spec.Command) string
- func VersionDetailed(appName string, userVersion string) string
- func VersionJSON(userVersion string) string
- func VersionSummary(appName string, userVersion string) string
- type BuildInfoData
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatWith ¶
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 RenderCompletionFooter ¶
func RenderCompletionFooter(cmdChain []*spec.Command, useFlag bool, detect func() (completion.CurrentShell, bool), width int) 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, and width carries the wrap width (zero resolves through termwidth). The per-shell instructions pointer is suppressed when the completion command's help flag is disabled, since the referenced invocation would be a usage error. An empty command chain renders nothing.
func RenderCompletionInstructions ¶
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 ¶
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, default, and bound environment variables. GA and deprecated features are omitted — they are no longer experimental — and the section renders nothing when no feature remains. Width carries the wrap width (zero resolves through termwidth). It is the feature-enabled implementation behind Options.FeaturesSection.
func VersionDetailed ¶
VersionDetailed formats the docker-style multi-line version block (for the `version` subcommand), with the full commit hash and commit timestamp.
func VersionJSON ¶
VersionJSON formats the flat machine-readable version object (for `version --json`). Every key is always present; unknown values are empty strings.
func VersionSummary ¶
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 {
// Width is the column width help text wraps at. Zero resolves through
// termwidth: a COLUMNS override when set, else the default width.
Width int
// 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
// completion screen.
CompletionFooter func(cmdChain []*spec.Command, useFlag bool, width int) 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, width int) 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.