From 048448c2437c7168ecc705d4f6fa1b391a383dfe Mon Sep 17 00:00:00 2001 From: rsteube Date: Fri, 11 Aug 2023 12:41:28 +0200 Subject: [PATCH] make: support directory change --- completers/make_completer/cmd/root.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/completers/make_completer/cmd/root.go b/completers/make_completer/cmd/root.go index bc05fed747..50c4b0965b 100644 --- a/completers/make_completer/cmd/root.go +++ b/completers/make_completer/cmd/root.go @@ -6,6 +6,7 @@ import ( "github.com/rsteube/carapace" "github.com/rsteube/carapace-bin/pkg/actions/tools/make" "github.com/spf13/cobra" + "github.com/spf13/pflag" ) var rootCmd = &cobra.Command{ @@ -85,4 +86,8 @@ func init() { return make.ActionTargets(file).FilterArgs() }), ) + + carapace.Gen(rootCmd).PreInvoke(func(cmd *cobra.Command, flag *pflag.Flag, action carapace.Action) carapace.Action { + return action.Chdir(rootCmd.Flag("directory").Value.String()) + }) }