feat(cli): add shell completions (#14341)

This commit is contained in:
Ethan
2024-08-20 14:47:46 +10:00
committed by GitHub
parent 6f9b3c1592
commit 0b2ba96065
80 changed files with 510 additions and 418 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ Aliases:
### {{ with $opt.FlagShorthand}}-{{ . }}, {{end}}--{{ $opt.Flag }}
{{" "}}
{{ tableHeader }}
| Type | {{ $opt.Value.Type | wrapCode }} |
| Type | {{ typeHelper $opt | wrapCode }} |
{{- with $opt.Env }}
| Environment | {{ (print "$" .) | wrapCode }} |
{{- end }}
+10
View File
@@ -62,6 +62,16 @@ func init() {
return `| | |
| --- | --- |`
},
"typeHelper": func(opt *serpent.Option) string {
switch v := opt.Value.(type) {
case *serpent.Enum:
return strings.Join(v.Choices, "\\|")
case *serpent.EnumArray:
return fmt.Sprintf("[%s]", strings.Join(v.Choices, "\\|"))
default:
return v.Type()
}
},
},
).Parse(strings.TrimSpace(commandTemplateRaw)),
)