tool

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdVersion = &Command{
	UsageLine: "version",
	Short:     "displays the program version",
	Run: func(_ *Command, _ io.Writer, _ []string) error {
		fmt.Println(Name, "version", Version)
		return nil
	},
}
View Source
var Commands []*Command

Commands lists the available commands and help topics. The order here is the order in which they are printed by 'go help'.

View Source
var ErrFormatPrefix string
View Source
var FormatErr = PrintErrExit
View Source
var Name string
View Source
var Title string
View Source
var Version = "<not set>"

Functions

func FilepathRelIfShorter

func FilepathRelIfShorter(fileName string) string

func FlagDefaults

func FlagDefaults(addFlags func(*flag.FlagSet)) string

func PrintErrExit

func PrintErrExit(err error)

func Run

func Run()

Types

type Command

type Command struct {
	// Run runs the command.
	// The args are the arguments after the command name.
	Run func(cmd *Command, w io.Writer, args []string) error

	// UsageLine is the one-line usage message.
	// The first word in the line is taken to be the command name.
	UsageLine string

	// Short is the short description shown in the 'go help' output.
	Short string

	// Long is the long message shown in the 'go help <this-command>' output.
	Long string

	// Flag is a set of flags specific to this command.
	Flag flag.FlagSet

	// CustomFlags indicates that the command will do its own
	// flag parsing.
	CustomFlags bool

	Hidden       bool
	ExtraArgsReq int
	ExtraArgsMax int
}

A Command is an implementation of a go command like go build or go fix.

func (*Command) Name

func (c *Command) Name() string

Name returns the command's name: the first word in the usage line.

func (*Command) Runnable

func (c *Command) Runnable() bool

Runnable reports whether the command can be run; otherwise it is a documentation pseudo-command such as importpath.

func (*Command) Usage

func (c *Command) Usage()

Jump to

Keyboard shortcuts

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