Exit with error code from subcommands as well as root command
This commit is contained in:
Kellen Fox 2017-08-02 14:04:07 -07:00 committed by stuart nelson
parent 7de7cf38f9
commit 09bc5dd8e5
1 changed files with 2 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net/url"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@ -92,6 +93,7 @@ func CommandWrapper(command func(*cobra.Command, []string) error) func(*cobra.Co
err := command(cmd, args)
if err != nil {
fmt.Printf("Error: %s\n", err)
os.Exit(1)
}
}
}