1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Get --module=[modname] working again (broke when position config validation was added)

This commit is contained in:
Chris Cummer 2019-07-06 01:55:54 -07:00
parent 2b2cdf912b
commit 2da3344612
5 changed files with 19 additions and 9 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/wtfutil/wtf/utils"
)
// Display displays the output of the --help argument
func Display(moduleName string, config *config.Config) {
if moduleName == "" {
fmt.Println("\n --module takes a module name as an argument, i.e: '--module=github'")
@ -17,9 +18,13 @@ func Display(moduleName string, config *config.Config) {
}
func helpFor(moduleName string, config *config.Config) string {
widget := maker.MakeWidget(nil, nil, moduleName, moduleName, config, config)
modConfig, _ := config.Get("wtf.mods." + moduleName)
widget := maker.MakeWidget(nil, nil, moduleName, moduleName, modConfig, config)
result := ""
result += utils.StripColorTags(widget.HelpText())
result += "\n"
result += "Configuration Attributes"
result += widget.ConfigText()
return result
}

View File

@ -223,6 +223,7 @@ func MakeWidgets(app *tview.Application, pages *tview.Pages, config *config.Conf
for mod := range mods {
modConfig, _ := config.Get("wtf.mods." + mod)
widgetType := modConfig.UString("type", mod)
if enabled := modConfig.UBool("enabled", false); enabled {
widget := MakeWidget(app, pages, mod, widgetType, modConfig, config)
widgets = append(widgets, widget)

View File

@ -51,8 +51,6 @@ func (widget *Widget) Refresh() {
widget.Render()
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) Render() {
if widget.result == nil {
return
@ -63,6 +61,8 @@ func (widget *Widget) Render() {
widget.Redraw(str, widget.contentFrom(widget.result), false)
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) openItem() {
sel := widget.GetSelected()
if sel >= 0 && widget.result != nil && sel < len(widget.result.Issues) {

View File

@ -28,20 +28,24 @@ func StripColorTags(input string) string {
func helpFromValue(field reflect.StructField) string {
result := ""
var help string = field.Tag.Get("help")
optional, err := strconv.ParseBool(field.Tag.Get("optional"))
if err != nil {
optional = false
}
var values string = field.Tag.Get("values")
help := field.Tag.Get("help")
if optional {
help = "Optional " + help
}
values := field.Tag.Get("values")
if help != "" {
result += "\n\n" + lowercaseTitle(field.Name)
result += "\n" + help
result += "\n\n " + lowercaseTitle(field.Name)
result += "\n " + help
if values != "" {
result += "\nValues: " + values
result += "\n Values: " + values
}
}
@ -49,7 +53,6 @@ func helpFromValue(field reflect.StructField) string {
}
func HelpFromInterface(item interface{}) string {
result := ""
t := reflect.TypeOf(item)

View File

@ -85,6 +85,7 @@ func (widget *KeyboardWidget) InputCapture(event *tcell.EventKey) *tcell.EventKe
return event
}
// HelpText returns the help text and keyboard command info for this widget
func (widget *KeyboardWidget) HelpText() string {
str := " [green::b]Keyboard commands for " + strings.Title(widget.settings.Module.Type) + "[white]\n\n"