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:
parent
5dce9de670
commit
9196a966c5
12
docs/docs.go
12
docs/docs.go
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user