-
Notifications
You must be signed in to change notification settings - Fork 0
/
exit.go
44 lines (35 loc) · 1.47 KB
/
exit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Package exit defines exit and error behavior of programs and commands.
//
//spellchecker:words exit
package exit
import (
"os"
)
// ExitCode determines the exit behavior of a program.
// These are returned as an exit code to the operating system.
// See ExitCode.Return().
type ExitCode uint8
// Return returns this ExitCode to the operating system by invoking os.Exit().
func (code ExitCode) Return() {
// NOTE: This function is untested
os.Exit(int(code))
}
const (
// ExitZero indicates that no error occurred.
// It is the zero value of type ExitCode.
ExitZero ExitCode = 0
// ExitGeneric indicates a generic error occurred within this invocation.
// This typically implies a subcommand-specific behavior wants to return failure to the caller.
ExitGeneric ExitCode = 1
// ExitUnknownCommand indicates that the user attempted to call a subcommand that is not defined.
ExitUnknownCommand ExitCode = 2
// ExitGeneralArguments indicates that the user attempted to pass invalid general arguments to the program.
ExitGeneralArguments ExitCode = 3
// ExitCommandArguments indicates that the user attempted to pass invalid command-specific arguments to a subcommand.
ExitCommandArguments ExitCode = 4
// ExitContext indicates an error with the underlying command context.
ExitContext ExitCode = 254
// ExitPanic indicates that the go code called panic() inside the execution of the current program.
// This typically implies a bug inside a program.
ExitPanic ExitCode = 255
)