Skip to content
Permalink
Browse files

Wrap command execution with global error check

This wraps the base command execute function call with an error check
so that all sub-commands that return an error will result in the main
executable returning a non-zero exit code. This is especially useful in
automated scripts for knowing if the k3sup command has failed.
The error messages are already handled elsewhere, this is only to set
and error exit code.

Signed-off-by: Burton Rheutan <rheutan7@gmail.com>
  • Loading branch information
burtonr authored and alexellis committed Jan 12, 2020
1 parent 8af48ea commit 9eaee3df6b959403b082f920bf11765c30420272
Showing with 5 additions and 1 deletion.
  1. +5 −1 main.go
@@ -1,6 +1,8 @@
package main

import (
"os"

"github.com/alexellis/k3sup/cmd"
"github.com/spf13/cobra"
)
@@ -28,5 +30,7 @@ func main() {
rootCmd.AddCommand(cmdApps)
rootCmd.AddCommand(cmdUpdate)

rootCmd.Execute()
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}

0 comments on commit 9eaee3d

Please sign in to comment.
You can’t perform that action at this time.