When a user uses a command that should return an error, the program will display a stylized error message but the return code is 0.
Update to the HandleCommandOutput() function.
Current:
func HandleCommandOutput(fn func() (string, error)) func() {
return func() {
output, err := fn()
if err != nil {
fmt.Fprintln(os.Stderr, output)
return
}
fmt.Println(output)
}
}
New:
func HandleCommandOutput(fn func() (string, error)) func() int {
return func() int {
output, err := fn()
if err != nil {
fmt.Fprintln(os.Stderr, output)
return 1
}
fmt.Println(output)
return 0
}
}
When a user uses a command that should return an error, the program will display a stylized error message but the return code is 0.
Update to the
HandleCommandOutput()function.Current:
New: