prog

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var ShowDeprecations = true

Global flag of whether to show deprecations.

Functions

func BadUsage

func BadUsage(msg string) error

BadUsage returns an error that may be returned by Program.Main, which requests the main program to print out a message, the usage information and exit with 2.

func Exit

func Exit(exit int) error

Exit returns an error that may be returned by Program.Main, which requests the main program to exit with the given code. If the exit code is 0, it returns nil.

func Run

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

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

func SetShowDeprecations

func SetShowDeprecations(b bool) func()

SetShowDeprecations sets ShowDeprecations to the given value, and returns a function to restore the old value.

Types

type Flags

type Flags struct {
	Log, LogPrefix, CPUProfile string

	Help, Version, BuildInfo, JSON bool

	CodeInArg, CompileOnly, NoRc bool

	Web  bool
	Port int

	Daemon bool
	Forked int

	Bin, DB, Sock string
}

Flags keeps command-line flags.

type Program

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

Program represents a subprogram.

Directories

Path Synopsis
Package progtest provides utilities for testing subprograms.
Package progtest provides utilities for testing subprograms.

Jump to

Keyboard shortcuts

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