0
0
mirror of https://github.com/thegeeklab/wp-plugin-go.git synced 2024-11-24 13:10:39 +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 {
reSlice := regexp.MustCompile(`^\*cli\.(.+?)SliceFlag$`)
if reSlice.MatchString(raw) {
return "list"
}
reMap := regexp.MustCompile(`^\*cli\.(.+?)MapFlag$`)
if reMap.MatchString(raw) {
return "dict"
}
re := regexp.MustCompile(`^\*cli\.(.+?)Flag$`)
match := re.FindStringSubmatch(raw)
if len(match) > 1 {
switch ctype := strings.ToLower(match[1]); ctype {
case "int", "int64", "uint", "uint64", "float64":
return "number"
case "int", "int64", "uint", "uint64":
return "integer"
case "float64":
return "float"
default:
return ctype
}

View File

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