mirror of https://github.com/cheat/cheat.git
feat: modify return codes
Modify exit codes. `cheat` now returns an exit code value `2` on errors pertaining to a cheatsheet not being found. BREAKING CHANGE
This commit is contained in:
parent
59d5c96c24
commit
49afd7c16b
|
@ -81,9 +81,9 @@ func cmdList(opts map[string]interface{}, conf config.Config) {
|
|||
flattened = filtered
|
||||
}
|
||||
|
||||
// exit early if no cheatsheets are available
|
||||
// return exit code 2 if no cheatsheets are available
|
||||
if len(flattened) == 0 {
|
||||
os.Exit(0)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
// initialize a tabwriter to produce cleanly columnized output
|
||||
|
|
|
@ -37,8 +37,8 @@ func cmdRemove(opts map[string]interface{}, conf config.Config) {
|
|||
// fail early if the requested cheatsheet does not exist
|
||||
sheet, ok := consolidated[cheatsheet]
|
||||
if !ok {
|
||||
fmt.Fprintln(os.Stderr, fmt.Sprintf("no cheatsheet found for '%s'.\n", cheatsheet))
|
||||
os.Exit(1)
|
||||
fmt.Fprintln(os.Stderr, fmt.Sprintf("No cheatsheet found for '%s'.\n", cheatsheet))
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
// fail early if the sheet is read-only
|
||||
|
|
|
@ -46,7 +46,7 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) {
|
|||
s, ok := consolidated[cheatsheet]
|
||||
if !ok {
|
||||
fmt.Printf("No cheatsheet found for '%s'.\n", cheatsheet)
|
||||
os.Exit(0)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
consolidated = map[string]sheet.Sheet{
|
||||
|
|
|
@ -39,7 +39,7 @@ func cmdView(opts map[string]interface{}, conf config.Config) {
|
|||
sheet, ok := consolidated[cheatsheet]
|
||||
if !ok {
|
||||
fmt.Printf("No cheatsheet found for '%s'.\n", cheatsheet)
|
||||
os.Exit(0)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
// apply colorization if requested
|
||||
|
|
|
@ -203,6 +203,13 @@ If set, autocompletion scripts will attempt to integrate with
|
|||
\f[B]fzf\f[].
|
||||
.RS
|
||||
.RE
|
||||
.SH RETURN VALUES
|
||||
.IP "0." 3
|
||||
Successful termination
|
||||
.IP "1." 3
|
||||
Application error
|
||||
.IP "2." 3
|
||||
Cheatsheet(s) not found
|
||||
.SH BUGS
|
||||
.PP
|
||||
See GitHub issues: <https://github.com/cheat/cheat/issues>
|
||||
|
|
|
@ -163,6 +163,15 @@ set, all other config paths will be ignored.
|
|||
|
||||
: If set, autocompletion scripts will attempt to integrate with **fzf**.
|
||||
|
||||
RETURN VALUES
|
||||
=============
|
||||
|
||||
0. Successful termination
|
||||
|
||||
1. Application error
|
||||
|
||||
2. Cheatsheet(s) not found
|
||||
|
||||
|
||||
BUGS
|
||||
====
|
||||
|
|
Loading…
Reference in New Issue