cli

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package cli handles command line arguments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Set *flag.FlagSet
	// contains filtered or unexported fields
}

Command describe a program sub command.

func NewCommand

func NewCommand(name string, desc string, fn func(s Commander) error) *Command

NewCommand makes a new Program instance.

type Commander

type Commander interface {
	// contains filtered or unexported methods
}

Commander is an generalizer of Command.

type Program

type Program struct {
	ProgramName    string
	ProgramVersion string
	Help           bool
	ShortHelp      bool
	Version        bool
	ShortVersion   bool
	// contains filtered or unexported fields
}

Program is a struct to define a program and its command.

func NewProgram

func NewProgram(name string, version string) *Program

NewProgram makes a new Program instance.

func (*Program) Add

func (p *Program) Add(c Commander) bool

Add a new sub command.

func (*Program) Bind

func (p *Program) Bind()

Bind help and version flag.

func (*Program) Run

func (p *Program) Run(args []string) error

Run the program against given set of arguments.

func (*Program) ShowCmdUsage

func (p *Program) ShowCmdUsage(cmd Commander) error

ShowCmdUsage prints command usage of given subCmd on stderr.

func (*Program) ShowUsage

func (p *Program) ShowUsage(subCmd string) error

ShowUsage prints program usage of given subCmd on stderr. If subCmd is empty, prints general usage.

func (*Program) ShowVersion

func (p *Program) ShowVersion() error

ShowVersion prints program name and version on stderr.

Jump to

Keyboard shortcuts

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