Compare commits
1 Commits
98c693b378
...
4866cfd31c
Author | SHA1 | Date | |
---|---|---|---|
4866cfd31c |
16
cli/run.go
16
cli/run.go
@ -3,6 +3,7 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"coopcloud.tech/abra/cli/app"
|
"coopcloud.tech/abra/cli/app"
|
||||||
"coopcloud.tech/abra/cli/catalogue"
|
"coopcloud.tech/abra/cli/catalogue"
|
||||||
@ -40,7 +41,7 @@ func Run(version, commit string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
if err := os.Mkdir(path, 0764); err != nil {
|
if err := os.Mkdir(path, 0o764); err != nil {
|
||||||
if !os.IsExist(err) {
|
if !os.IsExist(err) {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -66,8 +67,9 @@ func Run(version, commit string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||||
// This prevents displaying usage for errors returned from RunE
|
// We handle errors ourself
|
||||||
rootCmd.SilenceUsage = true
|
rootCmd.SilenceUsage = true
|
||||||
|
rootCmd.SilenceErrors = true
|
||||||
|
|
||||||
manCommand := &cobra.Command{
|
manCommand := &cobra.Command{
|
||||||
Use: "man [flags]",
|
Use: "man [flags]",
|
||||||
@ -214,7 +216,15 @@ func Run(version, commit string) {
|
|||||||
app.AppEnvCommand,
|
app.AppEnvCommand,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if cmd, err := rootCmd.ExecuteC(); err != nil {
|
||||||
|
fmt.Printf("Error: %s\n", err)
|
||||||
|
if strings.HasPrefix(err.Error(), "unknown flag") {
|
||||||
|
fmt.Println()
|
||||||
|
cmd.Usage()
|
||||||
|
} else if !internal.Debug {
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Printf("Run with --debug for more info.\n")
|
||||||
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user