prog

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: BSD-2-Clause Imports: 5 Imported by: 5

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 = 20

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.

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 NextProgram added in v0.19.0

func NextProgram(cleanups ...func([3]*os.File)) error

NextProgram returns a special error that may be returned by [Program.Run] that is part of a Composite program, indicating that the next program should be tried. It can carry a list of cleanup functions that should be run in reverse order before the Composite program finishes.

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 DaemonPaths added in v0.18.0

type DaemonPaths struct {
	DB, Sock string
}

type FlagSet added in v0.18.0

type FlagSet struct {
	*flag.FlagSet
	// contains filtered or unexported fields
}

func (*FlagSet) DaemonPaths added in v0.18.0

func (fs *FlagSet) DaemonPaths() *DaemonPaths

func (*FlagSet) JSON added in v0.18.0

func (fs *FlagSet) JSON() *bool

type Program

type Program interface {
	RegisterFlags(fs *FlagSet)
	// Run runs the subprogram.
	Run(fds [3]*os.File, 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