prog

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: BSD-2-Clause Imports: 7 Imported by: 4

Documentation

Overview

Package prog provides the entry point to Elvish. Its subpackages correspond to subprograms of Elvish.

Index

Constants

This section is empty.

Variables

View Source
var DeprecationLevel = 17

DeprecationLevel is a global flag that controls which deprecations to show. If its value is X, Elvish shows deprecations that should be shown for version 0.X.

View Source
var ErrNotSuitable = errors.New("internal error: no suitable subprogram")

ErrNotSuitable is a special error that may be returned by Program.Run, to signify that this Program should not be run. It is useful when a Program is used in Composite.

Functions

func BadUsage

func BadUsage(msg string) error

BadUsage returns a special error that may be returned by Program.Run. It causes the main function to print out a message, the usage information and exit with 2.

func Exit

func Exit(exit int) error

Exit returns a special error that may be returned by Program.Run. It causes the main function to exit with the given code without printing any error messages. Exit(0) returns nil.

func Run

func Run(fds [3]*os.File, args []string, p Program) int

Run parses command-line flags and runs the first applicable subprogram. It returns the exit status of the program.

Types

type Flags

type Flags struct {
	Log, CPUProfile string

	Help, Version, BuildInfo, JSON bool

	CodeInArg, CompileOnly, NoRc bool
	RC                           string

	Port int

	Daemon bool
	Forked int

	DB, Sock string
}

Flags keeps command-line flags.

type Program

type Program interface {
	// Run runs the subprogram.
	Run(fds [3]*os.File, f *Flags, args []string) error
}

Program represents a subprogram.

func Composite added in v0.17.0

func Composite(programs ...Program) Program

Composite returns a Program that tries each of the given programs, terminating at the first one that doesn't return NotSuitable().

Directories

Path Synopsis
Package progtest provides a framework for testing subprograms.
Package progtest provides a framework for testing subprograms.

Jump to

Keyboard shortcuts

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