Skip to content

Commit 591da33

Browse files
committed
feat: return non-zero exit code if error
1 parent 5bcf1d8 commit 591da33

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ package main
22

33
import (
44
"mjpclab.dev/ghfs/src"
5+
"os"
56
)
67

78
func main() {
8-
src.Main()
9+
ok := src.Main()
10+
if !ok {
11+
os.Exit(1)
12+
}
913
}

src/main.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ func reopenLogOnHup(appInst *app.App) {
3737
}()
3838
}
3939

40-
func Main() {
40+
func Main() (ok bool) {
4141
// params
4242
params, printVersion, printHelp, errs := param.ParseFromCli()
4343
if serverError.CheckError(errs...) {
4444
return
4545
}
4646
if printVersion {
4747
version.PrintVersion()
48-
return
48+
return true
4949
}
5050
if printHelp {
5151
param.PrintHelp()
52-
return
52+
return true
5353
}
5454

5555
// settings
@@ -77,5 +77,9 @@ func Main() {
7777
cleanupOnEnd(appInst)
7878
reopenLogOnHup(appInst)
7979
errs = appInst.Open()
80-
serverError.CheckError(errs...)
80+
if serverError.CheckError(errs...) {
81+
return
82+
}
83+
84+
return true
8185
}

0 commit comments

Comments
 (0)