Add `TakesFile` indicator to flag

This new member of `Flag` indicates if the flag expects a file as input.
This is especially useful for documentation and shell completion purposes.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
main
Sascha Grunert 5 years ago
parent 2e0e39a03b
commit e9e9e0ac5d
No known key found for this signature in database
GPG Key ID: 8CE029DD1A866E52

@ -46,9 +46,9 @@ var assets = func() http.FileSystem {
"/templates/cli_flags_generated.gotpl": &vfsgen۰CompressedFileInfo{
name: "cli_flags_generated.gotpl",
modTime: time.Time{},
uncompressedSize: 2575,
uncompressedSize: 2591,
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x55\x4d\x8f\xdb\x36\x10\x3d\x4b\xbf\x62\x6a\xe4\x20\x2d\x5c\xfb\xde\x20\xa7\x75\x36\x0d\x50\x24\x8b\xc6\xcd\x9d\x96\x86\x32\xb1\x34\xa9\x90\xa3\xdd\x2e\x0c\xff\xf7\x62\x48\xea\xc3\x1f\x58\xfb\xb2\x3d\x89\xe4\x0c\xdf\x7b\x7c\x33\xa4\x96\x4b\xb8\xb7\x35\x42\x83\x06\x9d\x20\xac\x61\xf3\x0a\xb2\xf9\x08\xab\xef\xf0\xed\xfb\x1a\x3e\xaf\xbe\xae\x17\x79\xde\x8a\xea\x49\x34\x08\xfb\x3d\x2c\x1e\xe3\xf8\x9b\xd8\x21\x1c\x0e\x79\xae\x76\xad\x75\x04\x45\x9e\xcd\xa4\x16\xcd\x8c\xbf\x3b\xe2\x8f\x27\x57\x59\xf3\xcc\x43\x52\x3b\x9c\xe5\x65\xbe\xdf\x83\x13\xa6\x41\xf8\xa0\xe6\xf0\x81\xf3\xe1\x8f\x4f\xb0\x78\xd0\xa2\xf1\x8c\xb6\x5c\x32\x47\x08\x2c\x12\x03\xc7\x40\x79\x10\x10\xd2\x5f\x14\x6d\x81\x5e\x5b\x1c\x13\xd7\x3c\x3b\x1c\x86\xf9\xca\x56\x24\x94\x66\xbc\xe3\xc4\x29\xa2\x27\xd7\x55\x04\xfb\x3c\xe3\xd5\x2c\xf3\xe4\x94\x69\xf2\xec\x1f\x2f\x9a\xc9\xf4\xb3\x79\xfe\x29\xdc\x38\x7f\x50\x1a\x1f\x05\x6d\x87\x85\xbf\xf1\x57\xa7\x1c\xd6\xd9\xc6\x5a\x9d\x67\x7f\xaa\xba\x46\x93\xa5\xd9\x7e\xff\x3b\x28\x09\xf8\x2b\x09\xf8\x29\x74\x87\x40\xae\x0b\xd6\x65\x61\x9a\x9d\x9e\x23\x6e\x43\x53\x0f\xe3\x29\xc4\x0a\x3d\x29\x23\x48\x59\x33\x02\x4d\x16\xb3\xbb\x37\xf1\x0e\x39\x7b\xfc\x23\x88\x07\x87\xd4\x39\xc3\xd6\x3a\x14\xb5\xd8\x68\x04\x87\xad\x43\x8f\x86\x22\x83\x95\x40\x5b\xe5\xe1\x99\x95\xf2\xce\x42\x5a\x07\x1d\x7b\x04\x35\x4a\xd1\x69\xf2\x65\x2e\x3b\x53\x41\x21\x2f\x1a\x5d\x26\xb2\xa2\x84\x68\x19\x5b\x1e\x89\x81\xe3\x31\x8a\xae\x90\x65\x12\xf7\x05\x29\xec\xef\xd5\xd1\x16\xc1\xf0\x42\x10\x83\xa1\x0d\xae\x50\x26\x88\x4b\x9c\x32\x64\x26\xaa\xaf\xbe\x2f\xdf\xc0\xf6\xb2\x45\xda\xa2\x03\xeb\xc0\x58\x1a\x08\xb9\x03\x5d\xca\xbd\x42\x3e\x82\x16\x25\x70\x1f\x1c\xb1\xf7\xb1\xa4\x60\x2d\x9e\xd0\xc7\xb6\x18\xce\xcb\x55\x9d\x9c\x15\x88\x73\x40\xc4\x22\xcc\xc1\xb2\xbe\x17\xe5\x11\xa4\xd0\x1e\xaf\xa8\x19\x09\xce\xd5\x0c\x3b\xa2\x80\xa1\x3d\xbe\x20\x85\x6b\x70\x54\x82\x58\xf4\xe4\x27\x77\xc1\xed\xb5\x08\x60\x97\x8b\x11\x42\x23\xed\x89\x13\x89\x21\xf5\x1f\x08\xdf\x43\x9c\xb4\xa9\x30\x35\x08\x03\xb8\x6b\xe9\x95\x91\x52\x96\x3a\x33\xd1\xd8\x1e\x8a\x40\x68\xbd\xb8\xae\xbd\xb7\x6e\xd4\x7e\xec\x5a\xba\x4a\x83\x77\xa7\x40\xa0\xad\x7d\xf2\xd0\xb5\x41\x4a\x24\xb7\x12\x04\x68\x5b\x09\x7d\x91\x77\xde\x1b\x70\x84\x77\x6f\x0d\xe1\xbf\xb4\x8a\xb7\x8e\x91\x95\x0c\x2d\x2a\x6d\x67\xfa\x9e\xac\xe0\x2e\xe5\x95\x67\xd0\x45\xb8\x44\xf1\x1c\x21\xca\xfb\x11\x7a\xe0\xf0\x5a\xcc\x66\xd3\x87\x74\x1a\x09\xcb\xa8\xfd\xd1\x4b\x3b\x44\xfa\xf7\x65\x52\x5b\x3e\x77\xd7\x5e\x14\x31\x87\x6a\xc1\x8b\x3f\x90\x86\x4b\xaf\xed\x46\xe8\x9b\xcd\x6b\x42\xfa\x7b\xba\x77\x59\xd0\xff\xe5\xa1\x92\x20\x3d\xff\x1a\xa3\x8b\x51\xcc\x43\xb4\xac\xb7\xb0\xfc\xc8\x39\xbf\x7d\x02\xa3\xc2\xa5\xbe\xc9\x78\xe9\xcb\x3c\x3b\x9c\xbf\x00\x67\xfe\x70\x5d\x82\x2b\x6f\xc0\x25\x23\xe6\xe0\x91\xe0\x2e\x84\x93\xc6\xf7\xf4\x46\xb2\x2f\x1e\x69\xf1\x57\x50\x16\x94\x94\xd1\xb2\xa9\x1b\xa3\x80\x47\xe1\x3c\xba\xc8\xdd\xf2\xb8\x9e\x03\x3a\xc7\x30\x03\x53\xca\x99\xaa\x38\x49\x95\xf1\xbe\x87\xb9\x75\x85\x51\xba\xe4\xdc\xf4\x9b\x66\x7a\x4e\x9c\x08\xb8\xc1\xe3\x8c\x4b\x71\xa6\xf4\x5e\x78\x8a\x6a\x4f\x11\x26\xf1\xa9\xd2\x94\x16\x05\x4f\x44\xdd\x58\xe7\x71\xc7\x7f\x01\x00\x00\xff\xff\xa4\x4d\x6e\xce\x0f\x0a\x00\x00"),
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x55\x4d\x8f\xdb\x36\x10\x3d\x4b\xbf\x62\x6a\xe4\x20\x2d\x5c\xfb\xde\x20\xa7\x75\x36\x0d\x50\x24\x8b\xc6\xcd\x9d\x96\x86\x32\xb1\x34\xa9\x90\xa3\xdd\x2e\x0c\xff\xf7\x62\x48\xea\xc3\x1f\x58\xfb\xb2\x3d\x59\xc3\x19\xbe\xf7\xf8\x66\x48\x2f\x97\x70\x6f\x6b\x84\x06\x0d\x3a\x41\x58\xc3\xe6\x15\x64\xf3\x11\x56\xdf\xe1\xdb\xf7\x35\x7c\x5e\x7d\x5d\x2f\xf2\xbc\x15\xd5\x93\x68\x10\xf6\x7b\x58\x3c\xc6\xef\x6f\x62\x87\x70\x38\xe4\xb9\xda\xb5\xd6\x11\x14\x79\x36\x93\x5a\x34\x33\xfe\xdd\x11\xff\x78\x72\x95\x35\xcf\xfc\x49\x6a\x87\xb3\xbc\xcc\xf7\x7b\x70\xc2\x34\x08\x1f\xd4\x1c\x3e\x70\x3d\xfc\xf1\x09\x16\x0f\x5a\x34\x9e\xd1\x96\x4b\xe6\x08\x89\x45\x62\xe0\x1c\x28\x0f\x02\x42\xf9\x8b\xa2\x2d\xd0\x6b\x8b\x63\xe1\x9a\xa3\xc3\x61\x88\x57\xb6\x22\xa1\x34\xe3\x1d\x17\x4e\x11\x3d\xb9\xae\x22\xd8\xe7\x19\xaf\x66\x99\x27\xa7\x4c\x93\x67\xff\x78\xd1\x4c\xc2\xcf\xe6\xf9\xa7\x70\x63\xfc\xa0\x34\x3e\x0a\xda\x0e\x0b\x7f\xe3\xaf\x4e\x39\xac\xb3\x8d\xb5\x3a\xcf\xfe\x54\x75\x8d\x26\x4b\xd1\x5a\x3c\xa1\xe7\x2d\x29\xde\xef\x7f\x07\x25\x01\x7f\x25\x41\x3f\x85\xee\x10\xc8\x75\xc1\xca\x2c\x84\xd9\xe9\xb9\xe2\x36\x34\xf5\xf0\x3d\x85\x58\xa1\x27\x65\x04\x29\x6b\x46\xa0\xc9\x62\x76\xf7\x26\xde\x21\x67\xcf\x7f\x84\xc3\x80\x43\xea\x9c\x61\xab\x1d\x8a\x5a\x6c\x34\x82\xc3\xd6\xa1\x47\x43\x91\xc1\x4a\xa0\xad\xf2\xf0\xcc\x4a\x79\x67\x21\xad\x83\x8e\x3d\x83\x1a\xa5\xe8\x34\xf9\x32\x97\x9d\xa9\xa0\x90\x17\x8d\x2f\x13\x59\x51\x42\xb4\x90\x5b\x10\x89\x81\xf3\x31\x8b\xae\x90\x65\x12\xf7\x05\x29\xec\xef\xd5\xd1\x16\xc1\xf0\x42\x10\x83\x61\x2c\xae\x50\x26\x88\x4b\x9c\x32\x54\x26\xaa\xaf\xbe\x6f\xe7\xc0\xf6\xb2\x45\xda\xa2\x03\xeb\xc0\x58\x1a\x08\x79\x22\x5d\xaa\xbd\x42\x3e\x82\x16\x25\xf0\x1c\x1c\xb1\xf7\xb9\xa4\x20\x4c\x4c\x1c\x8b\xe1\xbc\xdc\xd5\xc9\x59\x81\xb8\x06\x44\x6c\xc2\x1c\x2c\xeb\x7b\x51\x1e\x41\x0a\xed\xf1\x8a\x9a\x91\xe0\x5c\xcd\xb0\x23\x0a\x18\xc6\xe3\x0b\x52\xb8\x16\x47\x2d\x88\x4d\x4f\x7e\xf2\x14\xdc\xde\x8b\x00\x76\xb9\x19\x21\x35\xd2\x9e\x38\x91\x18\xd2\xfc\x81\xf0\x3d\xc4\xc9\x98\x0a\x53\x83\x30\x80\xbb\x96\x5e\x19\x29\x55\xa9\x33\x13\x8d\xed\xa1\x08\x84\xd6\x8b\xeb\xda\x7b\xeb\x46\xed\xc7\xae\xa5\xab\x34\x78\x77\x0a\x04\xda\xda\x27\x0f\x5d\x1b\xa4\x44\x72\x2b\x41\x80\xb6\x95\xd0\x17\x79\xe7\xbd\x01\x47\x78\xf7\xd6\x10\xfe\x4b\xab\x78\xeb\x18\x59\xc9\x30\xa2\xd2\x76\xa6\x9f\xc9\x0a\xee\x52\x5d\x79\x06\x5d\x84\x4b\x14\xcf\x11\xb2\xbc\x1f\xa1\x07\x0e\xaf\xc5\x6c\x36\x7d\x58\xa7\x99\xb0\x8c\xda\x1f\xbd\xbc\x43\xa6\x7f\x5f\x26\xbd\xe5\x73\x77\xed\x45\x11\x73\xa8\x16\xbc\xf8\x03\x69\xb8\xf4\xda\x6e\x84\xbe\xd9\xbc\x26\x94\xbf\xa7\x7b\x97\x05\xfd\x5f\x1e\x2a\x09\xd2\xf3\x5f\x65\x74\x31\x8a\x79\x88\x96\xf5\x16\x96\x1f\xb9\xe6\xb7\x4f\x60\x54\xb8\xd4\x37\x19\x2f\x7d\x99\x67\x87\xf3\x17\xe0\xcc\x1f\xee\x4b\x70\xe5\x0d\xb8\x64\xc4\x1c\x3c\x12\xdc\x85\x74\xd2\xf8\x9e\xde\x48\xf6\xc5\x23\x2d\xfe\x0a\xca\x82\x92\x32\x5a\x36\x75\x63\x14\xf0\x28\x9c\x47\x17\xb9\x5b\xfe\xae\xe7\x80\xce\x31\xcc\xc0\x94\x6a\xa6\x2a\x4e\x4a\x65\xbc\xef\x21\xb6\xae\x30\x4a\x97\x5c\x9b\xfe\xa6\x99\x9e\x0b\x27\x02\x6e\xf0\x38\xe3\x56\x9c\x29\xbd\x17\x9e\xa2\xda\x53\x84\x49\x7e\xaa\x34\x95\x45\xc1\x13\x51\x37\xf6\x79\xdc\xf1\x5f\x00\x00\x00\xff\xff\xdb\x2f\x5d\x87\x1f\x0a\x00\x00"),
},
}
fs["/"].(*vfsgen۰DirInfo).entries = []os.FileInfo{

@ -28,6 +28,7 @@ type FlagType struct {
Parser string `json:"parser"`
ParserCast string `json:"parser_cast"`
ValueString string `json:"valueString"`
TakesFile bool `json:"takes_file"`
}
func main() {

@ -17,6 +17,7 @@ type {{ $flag.Name }}Flag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
{{- if eq $flag.Value true }}
Value {{ $flag.Type }}
{{- end }}

@ -17,6 +17,7 @@ type BoolFlag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Destination *bool
}
@ -87,6 +88,7 @@ type BoolTFlag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Destination *bool
}
@ -157,6 +159,7 @@ type DurationFlag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value time.Duration
Destination *time.Duration
}
@ -228,6 +231,7 @@ type Float64Flag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value float64
Destination *float64
}
@ -299,6 +303,7 @@ type GenericFlag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value Generic
}
@ -372,6 +377,7 @@ type Int64Flag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value int64
Destination *int64
}
@ -443,6 +449,7 @@ type IntFlag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value int
Destination *int
}
@ -514,6 +521,7 @@ type IntSliceFlag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value *IntSlice
}
@ -587,6 +595,7 @@ type Int64SliceFlag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value *Int64Slice
}
@ -660,6 +669,7 @@ type StringFlag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value string
Destination *string
}
@ -731,6 +741,7 @@ type StringSliceFlag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value *StringSlice
}
@ -804,6 +815,7 @@ type Uint64Flag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value uint64
Destination *uint64
}
@ -875,6 +887,7 @@ type UintFlag struct {
FilePath string
Required bool
Hidden bool
TakesFile bool
Value uint
Destination *uint
}

Loading…
Cancel
Save