From b956f58f5eb6f368964b0caff68fc7de5989ab99 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sun, 29 Mar 2026 22:55:58 +0100 Subject: [PATCH] use CommandPath to catch completion subcommands --- .gitignore | 1 + cmd/root.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 124975f..022f17e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ *.dll *.so *.dylib +bin/ # Test binary, built with `go test -c` *.test diff --git a/cmd/root.go b/cmd/root.go index f65d2e2..de97967 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -28,7 +28,8 @@ It allows you to add, list, and delete patterns from the exclude file easily. This tool is particularly useful for developers who want to keep their repository clean by excluding certain files or directories from version control.`, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - if cmd.Name() == "completion" || cmd.Name() == "help" { + if strings.HasPrefix(cmd.CommandPath(), "exclude completion") || + strings.HasPrefix(cmd.CommandPath(), "exclude help") { return nil } @@ -46,7 +47,8 @@ by excluding certain files or directories from version control.`, return nil }, PersistentPostRunE: func(cmd *cobra.Command, args []string) error { - if cmd.Name() == "completion" || cmd.Name() == "help" { + if strings.HasPrefix(cmd.CommandPath(), "exclude completion") || + strings.HasPrefix(cmd.CommandPath(), "exclude help") { return nil }