1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-27 01:33:39 +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,
Args: cobra.NoArgs,
ValidArgsFunction: cobra.NoFileCompletions,
PreRun: func(cmd *cobra.Command, args []string) {
PreRun: func(cmd *cobra.Command, _ []string) {
if cmd.Flags().Lookup("language").Changed {
return
}
@ -85,9 +85,13 @@ func newInitCmd() *initCmd {
cmd.Flags().StringVarP(&root.config, "config", "f", ".goreleaser.yaml", "Load configuration from file")
_ = cmd.MarkFlagFilename("config", "yaml", "yml")
_ = cmd.RegisterFlagCompletionFunc("language", func(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{"go", "zig"}, cobra.ShellCompDirectiveDefault
})
_ = cmd.RegisterFlagCompletionFunc(
"language",
cobra.FixedCompletions(
[]string{"go", "zig"},
cobra.ShellCompDirectiveDefault,
),
)
root.cmd = cmd
return root