mirror of
https://github.com/thegeeklab/wp-plugin-go.git
synced 2024-11-21 14:10:39 +00:00
fix: dont add none-plugin flags to docs (#46)
This commit is contained in:
parent
ae9066d3cc
commit
ddde4d726e
@ -78,6 +78,7 @@ func prepareArgsWithValues(flags []cli.Flag) []*PluginArg {
|
||||
|
||||
func parseFlags(flags []cli.Flag) []*PluginArg {
|
||||
args := make([]*PluginArg, 0)
|
||||
namePrefix := "plugin_"
|
||||
|
||||
for _, f := range flags {
|
||||
flag, ok := f.(cli.DocGenerationFlag)
|
||||
@ -87,10 +88,12 @@ func parseFlags(flags []cli.Flag) []*PluginArg {
|
||||
|
||||
modArg := &PluginArg{}
|
||||
|
||||
name := flag.GetEnvVars()[0]
|
||||
name = strings.TrimPrefix(name, "PLUGIN_")
|
||||
modArg.Name = strings.ToLower(strings.TrimSpace(name))
|
||||
name := strings.ToLower(strings.TrimSpace(flag.GetEnvVars()[0]))
|
||||
if !strings.HasPrefix(name, namePrefix) {
|
||||
continue
|
||||
}
|
||||
|
||||
modArg.Name = strings.TrimPrefix(name, namePrefix)
|
||||
modArg.Description = flag.GetUsage()
|
||||
modArg.Default = flag.GetDefaultText()
|
||||
|
||||
|
@ -42,6 +42,11 @@ func testApp() *cli.App {
|
||||
Usage: "slice flag",
|
||||
EnvVars: []string{"PLUGIN_SLICE_FLAG"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "hidden.flag",
|
||||
Usage: "hidden flag",
|
||||
EnvVars: []string{"HIDDEN_FLAG", "PLUGIN_HIDDEN_FLAG"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user