diff --git a/go.mod b/go.mod index 23d8f231138..626e9ae5627 100644 --- a/go.mod +++ b/go.mod @@ -108,6 +108,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.4.1 // indirect + github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 // indirect github.com/xanzy/ssh-agent v0.3.2 // indirect github.com/yuin/goldmark v1.4.13 // indirect github.com/yuin/goldmark-emoji v1.0.1 // indirect diff --git a/go.sum b/go.sum index f1f1ca1f2a2..59f3688f554 100644 --- a/go.sum +++ b/go.sum @@ -461,6 +461,8 @@ github.com/twpayne/go-xdg/v6 v6.0.0 h1:kt2KGpflK5q8ZpkmQfX6kJphh6+oAWikf4LiAZxFT github.com/twpayne/go-xdg/v6 v6.0.0/go.mod h1:XlfiGBU0iBxudVRWh+SXF+I1Cfb7rMq1IFwOprG4Ts8= github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 h1:+dBg5k7nuTE38VVdoroRsT0Z88fmvdYrI2EjzJst35I= +github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1/go.mod h1:nmuySobZb4kFgFy6BptpXp/BBw+xFSyvVPP6auoJB4k= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/xanzy/ssh-agent v0.3.2 h1:eKj4SX2Fe7mui28ZgnFW5fmTz1EIr7ugo5s6wDxdHBM= github.com/xanzy/ssh-agent v0.3.2/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 1084791dcb3..297e7db983e 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -41,6 +41,7 @@ import ( "github.com/twpayne/go-shell" "github.com/twpayne/go-vfs/v4" "github.com/twpayne/go-xdg/v6" + cobracompletefig "github.com/withfig/autocomplete-tools/integrations/cobra" "go.uber.org/multierr" "golang.org/x/term" "mvdan.cc/sh/v3/expand" @@ -1454,6 +1455,7 @@ func (c *Config) newRootCmd() (*cobra.Command, error) { c.newUpdateCmd(), c.newUpgradeCmd(), c.newVerifyCmd(), + cobracompletefig.CreateCompletionSpecCommand(), } { if cmd != nil { rootCmd.AddCommand(cmd) diff --git a/pkg/cmd/testdata/scripts/generatefigspec.txtar b/pkg/cmd/testdata/scripts/generatefigspec.txtar new file mode 100644 index 00000000000..1455991d424 --- /dev/null +++ b/pkg/cmd/testdata/scripts/generatefigspec.txtar @@ -0,0 +1,3 @@ +# test that chezmoi generate-fig-spec generates a Fig spec +exec chezmoi generate-fig-spec +stdout 'const completionSpec:'