skip pre run hook for completion/help commands

This commit is contained in:
2026-03-29 23:12:16 +01:00
parent cfc5e93013
commit 5f7a48ee8e

View File

@@ -25,6 +25,11 @@ It allows users to easily create and manage .gitignore files for various program
You may also list available templates and generate .gitignore files based on those templates.`, You may also list available templates and generate .gitignore files based on those templates.`,
SilenceUsage: true, SilenceUsage: true,
PersistentPreRun: func(cmd *cobra.Command, _ []string) { PersistentPreRun: func(cmd *cobra.Command, _ []string) {
if strings.HasPrefix(cmd.CommandPath(), "exclude completion") ||
strings.HasPrefix(cmd.CommandPath(), "exclude help") {
return
}
var client *github.Client var client *github.Client
if !viper.IsSet("token") || viper.GetString("token") == "" { if !viper.IsSet("token") || viper.GetString("token") == "" {
client = github.NewClient(nil) client = github.NewClient(nil)