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) 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)) 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 ¶
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, 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 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 {
// 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) 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.