Documentation ¶
Overview ¶
Package base defines shared basic pieces of the go command, in particular logging and the Command structure. see also: https://pkg.go.dev/cmd/go/internal/base
Copyright (C) 2022 - Simon Travis. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUsage = errors.New("error: ")
ex. fmt.Errorf("%w expected at least one word to transform", base.ErrUsage)
var Exe string = "tap"
var Go = &Command{ UsageLine: Exe, Long: `The 'tap' tool manages Tapestry stories.`, }
var Interrupted = make(chan struct{})
Interrupted is closed when the go command receives an interrupt signal.
var SignalTrace os.Signal = unix.SIGQUIT
SignalTrace is the signal to send to make a Go program crash with a stack trace.
Functions ¶
func ExitWithStatus ¶
func ExitWithStatus(status int)
Types ¶
type Command ¶
type Command struct { // Run runs the command. // The args are the arguments after the command name. Run func(ctx context.Context, cmd *Command, args []string) error // UsageLine is the one-line usage message. // The words between "go" and the first flag or argument in the line are taken to be the command name. // ex. "go fix [-fix list] [packages]" UsageLine string // Short is the short description shown in the 'go help' output. // ex. "update packages to use new APIs" Short string // Long is the long message shown in the 'go help <this-command>' output. // ex. "Fix runs the Go fix command on the packages named by the import paths...." // -- see help.go which contains a template used to print the command Long string // Flag is a set of flags specific to this command. // unless CustomFlags is specified by the command: // main.invoke() merges global flags and calls calls .Parse automatically // any remaining args are sent to Run() // individual commands set their own flags using init() or local vars. // ex. go get: var getD = CmdGet.Flag.Bool("d", false, "") Flag flag.FlagSet // CustomFlags indicates that the command will do its own // flag parsing. see: Flag. CustomFlags bool // Commands lists the available commands and help topics. // The order here is the order in which they are printed by 'go help'. // Note that subcommands are in general best avoided. Commands []*Command }
A Command is an implementation of a go command like go build or go fix.
func (*Command) LongName ¶
LongName returns the command's long name: all the words in the usage line between "go" and a flag or argument,
func (*Command) Name ¶
Name returns the command's short name: the last word in the usage line before a flag or argument.