0
0
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:
Robert Kaussow 2024-01-01 18:07:31 +01:00 committed by GitHub
parent ae9066d3cc
commit ddde4d726e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -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()

View File

@ -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"},
},
},
}