Add helper method to exit with error code
This commit is contained in:
parent
c3495ac57a
commit
8364201d7b
@ -1,16 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
lumecmd "git.kill0.net/chill9/lume/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
exitCode, err := lumecmd.Main(os.Args)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", err)
|
||||
}
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
lumecmd.ExitWithCode(lumecmd.Main(os.Args))
|
||||
}
|
@ -2,6 +2,7 @@ package lumecmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -151,3 +152,10 @@ func sortResults(res []lifx.Result) {
|
||||
return res[i].Label < res[j].Label
|
||||
})
|
||||
}
|
||||
|
||||
func ExitWithCode(code int, err error) {
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", err)
|
||||
}
|
||||
os.Exit(code)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user