usage

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWrap = 80

Variables

This section is empty.

Functions

func Kind

func Kind(usable Usable) (kind, hint string)

func Usage

func Usage(width int, usables ...Usable) string

func Wrap

func Wrap(str string, indent string, width int) string

Wrap should not be used or relied upon outside cmdy. Changes to the API of Wrap will not be considered grounds for a semver bump. Use at your own risk.

Types

type Hinter

type Hinter interface {
	Hint() (kind, hint string)
}

Hinter allows flag.Var or arg.Var implementations to customise the type and hint portion of the usage output, for example:

--flag=<kind> (hint)

Empty strings will remove either part from the output:

--flag=<kind> (hint)
--flag (hint)

type Usable

type Usable interface {
	Name() string
	Usage() string
	DefValue() string
	Value() interface{}

	// Describe is used to format the description of this Usable in the usage
	// statement according to the Usable's preferredtemplate. Flags are
	// formatted differently to args, but the inputs are the same.
	Describe(kind string, hint string) string
}

Usable is a common interface that should support both flag.Flag and arg.Arg for the purpose of building a usage statement.

Jump to

Keyboard shortcuts

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