mirror of
https://github.com/taigrr/wtf
synced 2026-03-24 19:12:18 -07:00
WTF-748 Fixes and improves module templating (#786)
Fixes and improves the module templating for creating new bare-bones
text widgets.
This command:
WTF_WIDGET_NAME=MyNewWidget go generate -run=text
now properly generates:
* the module directory in the /modules directory
* the widget.go file
* the settings.go file
with no linter warnings or errors.
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
29
generator/settings.tpl
Normal file
29
generator/settings.tpl
Normal file
@@ -0,0 +1,29 @@
|
||||
package {{(Lower .Name)}}
|
||||
|
||||
import (
|
||||
"github.com/olebedev/config"
|
||||
"github.com/wtfutil/wtf/cfg"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultFocusable = false
|
||||
defaultTitle = "{{(.Name)}}"
|
||||
)
|
||||
|
||||
// Settings defines the configuration properties for this module
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
|
||||
// Define your settings attributes here
|
||||
}
|
||||
|
||||
// NewSettingsFromYAML creates a new settings instance from a YAML config block
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||
|
||||
// Configure your settings attributes here. See http://github.com/olebedev/config for type details
|
||||
}
|
||||
|
||||
return &settings
|
||||
}
|
||||
Reference in New Issue
Block a user