summaryrefslogtreecommitdiff
path: root/cmd/main.go
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2023-10-11 11:46:18 -0400
committerGitHub <noreply@github.com>2023-10-11 09:46:18 -0600
commit9c419f1e1a4a82a8ed49bac3d54050890cb3e58e (patch)
treed2ddc1499646eb0aa9dbf95a7f757a8df5d4a623 /cmd/main.go
parentb245ecd325428966ac4e4c208e268967d0e0cb83 (diff)
cmd: Fix exiting with custom status code, add `caddy -v` (#5874)
* Simplify variables for commands * Add --envfile support for adapt command * Carry custom status code for commands to os.Exit() * cmd: add `-v` and `--version` to root caddy command * Add `--envfile` to `caddy environ`, extract flag parsing to func --------- Co-authored-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Diffstat (limited to 'cmd/main.go')
-rw-r--r--cmd/main.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/cmd/main.go b/cmd/main.go
index b4e3fdc..fa15c08 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -17,6 +17,7 @@ package caddycmd
import (
"bufio"
"bytes"
+ "errors"
"flag"
"fmt"
"io"
@@ -63,6 +64,10 @@ func Main() {
}
if err := rootCmd.Execute(); err != nil {
+ var exitError *exitError
+ if errors.As(err, &exitError) {
+ os.Exit(exitError.ExitCode)
+ }
os.Exit(1)
}
}