show short help with -h (#76)

This commit is contained in:
T.v.Dein
2025-10-02 21:34:38 +02:00
committed by GitHub
parent 6f0f5afb27
commit 8c87da34f2
4 changed files with 27 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"os"
"slices"
"strings"
"github.com/spf13/cobra"
@@ -187,6 +188,11 @@ func Execute() {
rootCmd.SetUsageTemplate(strings.TrimSpace(usage) + "\n")
if slices.Contains(os.Args, "-h") {
fmt.Println(shortusage)
os.Exit(0)
}
err := rootCmd.Execute()
if err != nil {
os.Exit(1)