mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Simplify the inclusion of the Common config settings into each module
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
@@ -20,7 +20,7 @@ func (widget *Widget) content() (string, string, bool) {
|
||||
return title, " no columns defined", false
|
||||
}
|
||||
|
||||
str := fmt.Sprintf(" [::b][%s]", widget.settings.common.Colors.Subheading)
|
||||
str := fmt.Sprintf(" [::b][%s]", widget.settings.Colors.Subheading)
|
||||
|
||||
for _, colName := range columnSet {
|
||||
truncName := utils.Truncate(colName, maxColWidth, false)
|
||||
|
||||
@@ -24,7 +24,7 @@ var defaultColumns = []interface{}{
|
||||
|
||||
// Settings defines the configuration properties for this module
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
*cfg.Common
|
||||
|
||||
apiKey string `help:"Your DigitalOcean API key."`
|
||||
columns []string `help:"A list of the droplet properties to display."`
|
||||
@@ -35,7 +35,7 @@ type Settings struct {
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||
|
||||
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_DIGITALOCEAN_API_KEY"))),
|
||||
columns: utils.ToStrs(ymlConfig.UList("columns", defaultColumns)),
|
||||
|
||||
@@ -44,7 +44,7 @@ type Widget struct {
|
||||
// NewWidget creates a new instance of a widget
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.common),
|
||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
||||
|
||||
app: app,
|
||||
pages: pages,
|
||||
|
||||
Reference in New Issue
Block a user