Compare commits

..

1 Commits

Author SHA1 Message Date
98c693b378 feat: Introduces a new help error
All checks were successful
continuous-integration/drone/pr Build is passing
2025-03-13 10:15:02 +01:00

View File

@ -3,7 +3,6 @@ package cli
import (
"fmt"
"os"
"strings"
"coopcloud.tech/abra/cli/app"
"coopcloud.tech/abra/cli/catalogue"
@ -41,7 +40,7 @@ func Run(version, commit string) {
}
for _, path := range paths {
if err := os.Mkdir(path, 0o764); err != nil {
if err := os.Mkdir(path, 0764); err != nil {
if !os.IsExist(err) {
log.Fatal(err)
}
@ -67,9 +66,8 @@ func Run(version, commit string) {
}
rootCmd.CompletionOptions.DisableDefaultCmd = true
// We handle errors ourself
// This prevents displaying usage for errors returned from RunE
rootCmd.SilenceUsage = true
rootCmd.SilenceErrors = true
manCommand := &cobra.Command{
Use: "man [flags]",
@ -216,15 +214,7 @@ func Run(version, commit string) {
app.AppEnvCommand,
)
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")
}
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}