cmd

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: ISC Imports: 9 Imported by: 0

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

func Run(ctx *goal.Context, cfg Config) error

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

type ExitError struct {
	Msg  string // error message
	Code int    // exit status code
}

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).

func (*ExitError) Error added in v0.42.0

func (e *ExitError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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