Merge pull request #106 from eparis/bash-comp-docs
Make the filename extension bit of docs easier to read.
This commit is contained in:
		@ -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.
 | 
					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
 | 
					```go
 | 
				
			||||||
	annotations := make([]string, 3)
 | 
						annotations := []string{"json", "yaml", "yml"}
 | 
				
			||||||
	annotations[0] = "json"
 | 
					 | 
				
			||||||
	annotations[1] = "yaml"
 | 
					 | 
				
			||||||
	annotations[2] = "yml"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	annotation := make(map[string][]string)
 | 
						annotation := make(map[string][]string)
 | 
				
			||||||
	annotation[cobra.BashCompFilenameExt] = annotations
 | 
						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)
 | 
						cmd.Flags().AddFlag(flag)
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user