Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#2075·cli

Improve readability of help text

Author: slawoCreated Mar 11, 2025Updated Sep 19, 2026
Labelskind/featurearea/v3

Checklist

  • Are you running the latest v3 release? The list of releases is here.
  • Did you check the manual for your release? The v3 manual is here.
  • Did you perform a search about this feature? Here's the GitHub guide about searching.

What problem does this solve?

Currently help text for flags is not very readable and looks all over the place, even when defining a custom Printer with a custom wrapAt

ex:

GLOBAL OPTIONS:
   --listen value, --address value     address on which the router will be listening on, ie: "localhost:11434"
                                              (default: "localhost:11434") [$GOLLAMAS_LISTEN, $LISTEN]
   --level value, --error-level value  error level, can be any of panic|fatal|error|warning|info|debug|trace
                                              (default: "error") [$GOLLAMAS_LEVEL, $LEVEL]
   --proxy value [ --proxy value ] assigns a destination for a model, can be a url or a connection id ex: --proxy
      'llama3.2-vision=http://server:11434'] ex: --proxy 'llama3.2-vision=c1 --connection c1=http://server:11434'
   --proxies value assigns destinations for the models, in the list of model=destination pairs ex: --proxies
      'llama3.2-vision=http://server:11434,deepseek-r1:14b=http://server2:11434' [$GOLLAMAS_PROXIES, $PROXIES]
   --connection value [ --connection value ] assigns an identifier to a connection which can be reffered to by
      proxy declarations ex: --connection c1=http://server:11434 --proxy llama=c1

GLOBAL OPTIONS:
   --listen value, --address value address on which the router will be listening
      on, ie: "localhost:11434"
               (default: "localhost:11434") [$GOLLAMAS_LISTEN, $LISTEN]
   --level value, --error-level value error level, can be any of
      panic|fatal|error|warning|info|debug|trace
               (default: "error") [$GOLLAMAS_LEVEL, $LEVEL]
   --proxy value [ --proxy value ] assigns a destination for a model, can be a url
      or a connection id ex: --proxy 'llama3.2-vision=http://server:11434'] ex:
      --proxy 'llama3.2-vision=c1 --connection c1=http://server:11434'
   --proxies value assigns destinations for the models, in the list of
      model=destination pairs ex: --proxies
      'llama3.2-vision=http://server:11434,deepseek-r1:14b=http://server2:11434'
      [$GOLLAMAS_PROXIES, $PROXIES]
   --connection value [ --connection value ] assigns an identifier to a connection
      which can be reffered to by proxy declarations ex: --connection
      c1=http://server:11434 --proxy llama=c1
   --connections value provides a list of connections which can be reffered to by
      id ex: --connections c1=http://server:11434,c2=http://server2:11434
      [$GOLLAMAS_CONNECTIONS, $CONNECTIONS]

Notice when a default is declared the line for default indents further and is more readable.

Solution description

The lines which have been wrapped should also be indented to the same level as the (default: ... ) text or simply to the start of the description column like in the docker documentation:


Global Options:
      --config string      Location of client config files (default
                           "/home/vscode/.docker")
  -c, --context string     Name of the context to use to connect to the daemon
                           (overrides DOCKER_HOST env var and default context
                           set with "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket to connect to
  -l, --log-level string   Set the logging level ("debug", "info", "warn",
                           "error", "fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify

currently I use this function to wrap the lines in the helper:

	cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) {
		funcMap := map[string]interface{}{
			"wrapAt": func() int {
				w := 10000
				tid := int(os.Stdout.Fd())
				if term.IsTerminal(tid) {
					width, _, err := term.GetSize(tid)
					println("width", width)
					if err == nil {
						w = width - 1
					}
				}
				return w
			},
		}

		cli.HelpPrinterCustom(w, templ, data, funcMap)
	}

I would like the behavior to be:

  • wrapped lines start at the beginning of the description column
  • if there is not enough space they display like the default line
  • if necessary I would like to pass a function to override that behavior with something like "wrapTo":func(int) or "indentBy":func(int)

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Source: urfave/cli

View original on GitHubView discussion on GitHub