diff --git a/bash_completions.md b/bash_completions.md index e1a5d56d..f6707ff0 100644 --- a/bash_completions.md +++ b/bash_completions.md @@ -123,15 +123,18 @@ and you'll get something like In this example we use --filename= and expect to get a json or yaml file as the argument. To make this easier we annotate the --filename flag with valid filename extensions. ```go - annotations := make([]string, 3) - annotations[0] = "json" - annotations[1] = "yaml" - annotations[2] = "yml" - + annotations := []string{"json", "yaml", "yml"} annotation := make(map[string][]string) annotation[cobra.BashCompFilenameExt] = annotations - flag := &pflag.Flag{"filename", "f", usage, value, value.String(), false, annotation} + flag := &pflag.Flag{ + Name: "filename", + Shorthand: "f", + Usage: usage, + Value: value, + DefValue: value.String(), + Annotations: annotation, + } cmd.Flags().AddFlag(flag) ```