0
0
mirror of https://github.com/thegeeklab/wp-plugin-go.git synced 2024-11-22 00:20:38 +00:00

fix: fix doc types and add missing dict (#48)

This commit is contained in:
Robert Kaussow 2024-01-02 21:46:32 +01:00 committed by GitHub
parent 5dce9de670
commit 9196a966c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -115,18 +115,24 @@ func parseFlags(flags []cli.Flag) []*PluginArg {
func parseType(raw string) string { func parseType(raw string) string {
reSlice := regexp.MustCompile(`^\*cli\.(.+?)SliceFlag$`) reSlice := regexp.MustCompile(`^\*cli\.(.+?)SliceFlag$`)
if reSlice.MatchString(raw) { if reSlice.MatchString(raw) {
return "list" return "list"
} }
reMap := regexp.MustCompile(`^\*cli\.(.+?)MapFlag$`)
if reMap.MatchString(raw) {
return "dict"
}
re := regexp.MustCompile(`^\*cli\.(.+?)Flag$`) re := regexp.MustCompile(`^\*cli\.(.+?)Flag$`)
match := re.FindStringSubmatch(raw) match := re.FindStringSubmatch(raw)
if len(match) > 1 { if len(match) > 1 {
switch ctype := strings.ToLower(match[1]); ctype { switch ctype := strings.ToLower(match[1]); ctype {
case "int", "int64", "uint", "uint64", "float64": case "int", "int64", "uint", "uint64":
return "number" return "integer"
case "float64":
return "float"
default: default:
return ctype return ctype
} }

View File

@ -113,7 +113,7 @@ func TestToData(t *testing.T) {
Name: "dummy_flag_int", Name: "dummy_flag_int",
Description: "dummy int flag desc", Description: "dummy int flag desc",
Default: "10", Default: "10",
Type: "number", Type: "integer",
Required: true, Required: true,
}, },
{ {