fix: ensure official golang plugins have correct help output

Previously, golang plugins would omit subcommands for 'dokku help --all', meaning they could not be introspected upon by outside tooling.
This commit is contained in:
Jose Diaz-Gonzalez
2019-01-20 22:50:48 -05:00
parent b7e5bbed08
commit af8718cebe
3 changed files with 34 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ import (
"strconv"
"strings"
"github.com/dokku/dokku/plugins/common"
columnize "github.com/ryanuber/columnize"
)
@@ -34,7 +35,15 @@ func main() {
case "network", "network:help":
usage()
case "help":
fmt.Print("\n network, Manages network settings for an app\n")
command := common.NewShellCmd(fmt.Sprintf("ps -o command= %d", os.Getppid()))
command.ShowOutput = false
output, err := command.Output()
if err == nil && strings.Contains(string(output), "--all") {
fmt.Println(helpContent)
} else {
fmt.Print("\n network, Manages network settings for an app\n")
}
default:
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))
if err != nil {
@@ -46,11 +55,11 @@ func main() {
}
func usage() {
fmt.Println(helpHeader)
config := columnize.DefaultConfig()
config.Delim = ","
config.Prefix = " "
config.Empty = ""
content := strings.Split(helpContent, "\n")[1:]
fmt.Println(helpHeader)
fmt.Println(columnize.Format(content, config))
}