cli

package module
v0.0.0-...-b60d492 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 12 Imported by: 1

README

cli

Simple library to build command-line interfaces using only the Go standard library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultShortUsage

func DefaultShortUsage(c *Command) string

func DefaultUsage

func DefaultUsage(c *Command) string

Types

type BuildInfo

type BuildInfo struct {
	// contains filtered or unexported fields
}

func NewBuildInfo

func NewBuildInfo(version string) *BuildInfo

func (*BuildInfo) GoVersion

func (bi *BuildInfo) GoVersion() string

func (*BuildInfo) Modified

func (bi *BuildInfo) Modified() bool

func (*BuildInfo) Revision

func (bi *BuildInfo) Revision() string

func (*BuildInfo) Time

func (bi *BuildInfo) Time() string

func (*BuildInfo) Version

func (bi *BuildInfo) Version() string

type Command

type Command struct {
	Name       string
	ShortHelp  string
	ShortUsage string
	LongHelp   string

	Flags *flag.FlagSet
	Exec  func(ctx context.Context, args []string) error

	Subcommands []*Command
	// contains filtered or unexported fields
}

func DefaultVersionCommand

func DefaultVersionCommand(out io.Writer) *Command

func NewVersionCommand

func NewVersionCommand(info VersionInfo, out io.Writer) *Command

func (*Command) Parse

func (cmd *Command) Parse(args []string, options ...ParseOption) error

func (*Command) Run

func (cmd *Command) Run(ctx context.Context) (err error)

type ParseOption

type ParseOption func(*ParseOptions) error

func WithEnvVarPrefix

func WithEnvVarPrefix(prefix string) ParseOption

func WithEnvVars

func WithEnvVars() ParseOption

type ParseOptions

type ParseOptions struct {
	// contains filtered or unexported fields
}

type VersionInfo

type VersionInfo interface {
	// The version number
	Version() string

	// The revision identifier of the commit
	Revision() string

	// The modification time of the commit, in RFC3339 format
	Time() string

	// Whether the source tree had uncommitted local changes
	Modified() bool

	// The version of the Go toolchain that built the binary
	GoVersion() string
}

func DefaultVersionInfo

func DefaultVersionInfo() VersionInfo

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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