Help us shape the future of Go! Take the 2026 Go Developer Survey

clihelp

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package clihelp prints the flag section of a command's --help the same way for every AgentGuard binary: flags written as --flag, grouped under titles, descriptions wrapped to 80 columns, an alias on its flag's line, and a note saying how to turn off a bool flag that is on by default.

It is internal to the module: agentguard, agentguard-mcp-gateway and agentguard-llm-proxy share it, and nothing outside imports it.

Index

Constants

View Source
const Ungrouped = "Ungrouped"

Ungrouped is the title of the group that catches flags no group names. A help page that shows it has a flag missing from its group list.

View Source
const Width = 80

Width is the column the help wraps at.

Variables

This section is empty.

Functions

func Wrap

func Wrap(s string, width int) []string

Wrap splits s into lines of at most width characters, breaking at spaces. A single word longer than width gets a line of its own.

func WriteFlags

func WriteFlags(w io.Writer, fs *flag.FlagSet, opt Options)

WriteFlags prints every flag of fs, alphabetically, under "Flags:".

func WriteGroups

func WriteGroups(w io.Writer, fs *flag.FlagSet, groups []Group, opt Options)

WriteGroups prints fs's flags under the given groups. A flag that is neither in a group nor an alias is printed under Ungrouped, so nothing is ever missing from the help.

Types

type Group

type Group struct {
	Title string
	Names []string
}

Group is a titled set of flags, printed in the order given.

type Options

type Options struct {
	// Aliases maps an alias to the flag it stands for. The alias is printed
	// on that flag's line ("--url, --guard-url string"), not on its own.
	Aliases map[string]string
	// HideDefault names flags whose "(default …)" note would mislead,
	// because the page explains what happens when the flag isn't given.
	HideDefault map[string]bool
}

Options adjusts how flags are printed.

Jump to

Keyboard shortcuts

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