Documentation ¶
Overview ¶
Package cmd provides a quick way to create derived interpreters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exit ¶ added in v1.0.0
func Exit(err error)
Exit causes the current program to exit with status code depending on the given error value. If the error is nil, then code zero is used. Otherwise, the error message is displayed on os.Stderr, and a non-zero code is used. If err is of type *ExitError, status code is read from the Code field, otherwise it defaults to 1.
func Run ¶ added in v1.0.0
Run runs a goal interpreter with starting context ctx and the given help strings when using the repl. Command line usage is then as follows:
program-name [-d] [-i] [-q] [-version] [-e command | script] [args ...]
The ARGS global variable contains the arguments, starting from script name if given.
Types ¶
type Config ¶
type Config struct { Help func(string) string // defaults to disabling help if nil ProgramName string // defaults to os.Args[0] if empty Man string // defaults to none if empty }
Config describes the possible configuration options when running a *goal.Context through Run.
type ExitError ¶ added in v0.42.0
ExitError is returned by Run when the program returns a Goal error value. Msg contains the error message. Code is 1 by default. If the error value is a dict value with a code key, following the same convention as the run builtin, then Code is set to the corresponding value (if it is an integer in the [1,125] range).