From f28605cdf8f1f63cd69c93ea53367acf4bd459a1 Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Sun, 11 Aug 2019 21:49:01 -0400 Subject: [PATCH] Fix help for modules This does 2 things: 1. Forces a module to be 'enabled' on the help route, so that it works 2. Better handling when no module is actually found --- help/help.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/help/help.go b/help/help.go index ccc1cbb9..369813d8 100644 --- a/help/help.go +++ b/help/help.go @@ -9,16 +9,23 @@ import ( ) // Display displays the output of the --help argument -func Display(moduleName string, config *config.Config) { +func Display(moduleName string, cfg *config.Config) { if moduleName == "" { fmt.Println("\n --module takes a module name as an argument, i.e: '--module=github'") } else { - fmt.Printf("%s\n", helpFor(moduleName, config)) + fmt.Printf("%s\n", helpFor(moduleName, cfg)) } } -func helpFor(moduleName string, config *config.Config) string { - widget := app.MakeWidget(nil, nil, moduleName, config) +func helpFor(moduleName string, cfg *config.Config) string { + cfg.Set("wtf.mods."+moduleName+".enabled", true) + widget := app.MakeWidget(nil, nil, moduleName, cfg) + + // Since we are forcing enabled config, if no module + // exists, we will get the unknown one + if widget.CommonSettings().Title == "Unknown" { + return "Unable to find module " + moduleName + } result := "" result += utils.StripColorTags(widget.HelpText())