1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-14 03:51:24 +02:00

fix(init): complete --language

This commit is contained in:
Carlos Alexandro Becker 2024-11-28 22:58:13 -03:00
parent 6d1429da72
commit 7d6311e73b
No known key found for this signature in database

View File

@ -28,7 +28,7 @@ func newInitCmd() *initCmd {
SilenceErrors: true, SilenceErrors: true,
Args: cobra.NoArgs, Args: cobra.NoArgs,
ValidArgsFunction: cobra.NoFileCompletions, ValidArgsFunction: cobra.NoFileCompletions,
PreRun: func(cmd *cobra.Command, args []string) { PreRun: func(cmd *cobra.Command, _ []string) {
if cmd.Flags().Lookup("language").Changed { if cmd.Flags().Lookup("language").Changed {
return return
} }
@ -85,9 +85,13 @@ func newInitCmd() *initCmd {
cmd.Flags().StringVarP(&root.config, "config", "f", ".goreleaser.yaml", "Load configuration from file") cmd.Flags().StringVarP(&root.config, "config", "f", ".goreleaser.yaml", "Load configuration from file")
_ = cmd.MarkFlagFilename("config", "yaml", "yml") _ = cmd.MarkFlagFilename("config", "yaml", "yml")
_ = cmd.RegisterFlagCompletionFunc("language", func(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) { _ = cmd.RegisterFlagCompletionFunc(
return []string{"go", "zig"}, cobra.ShellCompDirectiveDefault "language",
}) cobra.FixedCompletions(
[]string{"go", "zig"},
cobra.ShellCompDirectiveDefault,
),
)
root.cmd = cmd root.cmd = cmd
return root return root