mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
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
This commit is contained in:
parent
9b6947dc98
commit
f28605cdf8
15
help/help.go
15
help/help.go
@ -9,16 +9,23 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Display displays the output of the --help argument
|
// Display displays the output of the --help argument
|
||||||
func Display(moduleName string, config *config.Config) {
|
func Display(moduleName string, cfg *config.Config) {
|
||||||
if moduleName == "" {
|
if moduleName == "" {
|
||||||
fmt.Println("\n --module takes a module name as an argument, i.e: '--module=github'")
|
fmt.Println("\n --module takes a module name as an argument, i.e: '--module=github'")
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s\n", helpFor(moduleName, config))
|
fmt.Printf("%s\n", helpFor(moduleName, cfg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func helpFor(moduleName string, config *config.Config) string {
|
func helpFor(moduleName string, cfg *config.Config) string {
|
||||||
widget := app.MakeWidget(nil, nil, moduleName, config)
|
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 := ""
|
||||||
result += utils.StripColorTags(widget.HelpText())
|
result += utils.StripColorTags(widget.HelpText())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user