1
0
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:
Chris Cummer 2020-11-26 19:53:21 -08:00
parent f9a06540f1
commit d6a0797bf2
161 changed files with 378 additions and 330 deletions

View File

@ -28,13 +28,16 @@ type Common struct {
PositionSettings `help:"Defines where in the grid this modules widget will be displayed."`
Sigils
Colors ColorTheme
Colors ColorTheme
Config *config.Config
DocPath string
Bordered bool `help:"Whether or not the module should be displayed with a border." values:"true, false" optional:"true" default:"true"`
Enabled bool `help:"Whether or not this module is executed and if its data displayed onscreen." values:"true, false" optional:"true" default:"false"`
Focusable bool `help:"Whether or not this module is focusable." values:"true, false" optional:"true" default:"false"`
RefreshInterval int `help:"How often, in seconds, this module will update its data." values:"A positive integer, 0..n." optional:"true"`
Title string `help:"The title string to show when displaying this module" optional:"true"`
Config *config.Config
focusChar int `help:"Define one of the number keys as a short cut key to access the widget." optional:"true"`
}
@ -167,6 +170,15 @@ func (common *Common) PaginationMarker(len, pos, width int) string {
return sigils
}
// SetDocumentationPath is used to explicitly set the documentation path that should be opened
// when the key to open the documentation is pressed.
// Setting this is probably not necessary unless the module documentation is nested inside a
// documentation subdirectory in the /wtfutildocs repo, or the module here has a different
// name than the module's display name in the documentation (which ideally wouldn't be a thing).
func (common *Common) SetDocumentationPath(path string) {
common.DocPath = path
}
// Validations aggregates all the validations from all the sub-sections in Common into a
// single array of validations
func (common *Common) Validations() []Validatable {

View File

@ -14,7 +14,7 @@ const (
// Settings defines the configuration options for this module
type Settings struct {
common *cfg.Common
*cfg.Common
apiToken string `help:"Your Azure DevOps Access Token."`
labelColor string
@ -26,7 +26,7 @@ type Settings struct {
// NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocus, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocus, ymlConfig, globalConfig),
apiToken: ymlConfig.UString("apiToken", os.Getenv("WTF_AZURE_DEVOPS_API_TOKEN")),
labelColor: ymlConfig.UString("labelColor", "white"),

View File

@ -21,7 +21,7 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, pages, settings.common),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
settings: settings,
}

View File

@ -13,7 +13,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your BambooHR API token."`
subdomain string `help:"Your BambooHR API subdomain name."`
@ -21,7 +21,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_BAMBOO_HR_TOKEN"))),
subdomain: ymlConfig.UString("subdomain", os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN")),

View File

@ -21,7 +21,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
}

View File

@ -11,12 +11,12 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
}
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),
}
return &settings

View File

@ -23,7 +23,7 @@ type Widget struct {
// NewWidget Make new instance of widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
BarGraph: view.NewBarGraph(app, "Sample Bar Graph", settings.common),
BarGraph: view.NewBarGraph(app, "Sample Bar Graph", settings.Common),
app: app,
}

View File

@ -21,7 +21,8 @@ type PipelineSettings struct {
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your Buildkite API Token"`
orgSlug string `help:"Organization Slug"`
pipelines []PipelineSettings `help:"An array of pipelines to get data from"`
@ -30,7 +31,8 @@ type Settings struct {
// 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),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_BUILDKITE_TOKEN")),
orgSlug: ymlConfig.UString("organizationSlug"),
pipelines: buildPipelineSettings(ymlConfig),

View File

@ -17,7 +17,7 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, pages, settings.common),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
settings: settings,
}

View File

@ -25,7 +25,7 @@ func (widget *Widget) content() (string, string, bool) {
}
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.PaginationMarker(len(widget.workflows), widget.Idx, width) + "\n"
str := widget.settings.PaginationMarker(len(widget.workflows), widget.Idx, width) + "\n"
title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.title(workflow))
str += widget.displayWorkflowRuns(workflow)
@ -36,7 +36,7 @@ func (widget *Widget) content() (string, string, bool) {
func (widget *Widget) title(workflow *sdk.Workflow) string {
return fmt.Sprintf(
"[%s]%s/%s[white]",
widget.settings.common.Colors.TextTheme.Title,
widget.settings.Colors.TextTheme.Title,
workflow.ProjectKey, workflow.Name,
)
}

View File

@ -15,7 +15,8 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
token string `help:"Your CDS API token."`
apiURL string `help:"Your CDS API URL."`
uiURL string
@ -25,7 +26,8 @@ type Settings struct {
// 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),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
token: ymlConfig.UString("token", ymlConfig.UString("token", os.Getenv("CDS_TOKEN"))),
apiURL: ymlConfig.UString("apiURL", os.Getenv("CDS_API_URL")),
hideTags: utils.ToStrs(ymlConfig.UList("hideTags")),

View File

@ -29,8 +29,8 @@ type Widget struct {
// NewWidget creates a new instance of the widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "workflow", "workflows"),
TextWidget: view.NewTextWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
settings: settings,
}

View File

@ -23,7 +23,7 @@ func (widget *Widget) content() (string, string, bool) {
filter := widget.currentFilter()
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.PaginationMarker(len(widget.filters), widget.Idx, width) + "\n"
str := widget.settings.PaginationMarker(len(widget.filters), widget.Idx, width) + "\n"
str += widget.displayQueue(filter)
title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.title(filter))
@ -34,7 +34,7 @@ func (widget *Widget) content() (string, string, bool) {
func (widget *Widget) title(filter string) string {
return fmt.Sprintf(
"[%s]%d - %s[white]",
widget.settings.common.Colors.TextTheme.Title,
widget.settings.Colors.TextTheme.Title,
widget.maxItems,
filter,
)

View File

@ -14,7 +14,8 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
token string `help:"Your CDS API token."`
apiURL string `help:"Your CDS API URL."`
uiURL string
@ -23,7 +24,8 @@ type Settings struct {
// 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),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
token: ymlConfig.UString("token", ymlConfig.UString("token", os.Getenv("CDS_TOKEN"))),
apiURL: ymlConfig.UString("apiURL", os.Getenv("CDS_API_URL")),
}

View File

@ -29,8 +29,8 @@ type Widget struct {
// NewWidget creates a new instance of the widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "workflow", "workflows"),
TextWidget: view.NewTextWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
settings: settings,
}

View File

@ -13,7 +13,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your CircleCI API token."`
numberOfBuilds int `help:"The number of build, 10 by default"`
@ -22,7 +22,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_CIRCLE_API_KEY"))),
numberOfBuilds: ymlConfig.UInt("numberOfBuilds", 10),

View File

@ -16,7 +16,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
Client: NewClient(settings.apiKey),
settings: settings,

View File

@ -13,7 +13,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
dateFormat string `help:"The format of the date string for all clocks." values:"Any valid Go date layout which is handled by Time.Format. Defaults to Jan 2."`
timeFormat string `help:"The format of the time string for all clocks." values:"Any valid Go time layout which is handled by Time.Format. Defaults to 15:04 MST."`
@ -24,7 +24,7 @@ type Settings struct {
// 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),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
dateFormat: ymlConfig.UString("dateFormat", utils.SimpleDateFormat),
timeFormat: ymlConfig.UString("timeFormat", utils.SimpleTimeFormat),

View File

@ -17,7 +17,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
app: app,
settings: settings,

View File

@ -13,7 +13,7 @@ const (
// Settings for the cmdrunner widget
type Settings struct {
common *cfg.Common
*cfg.Common
args []string `help:"The arguments to the command, with each item as an element in an array. Example: for curl -I cisco.com, the arguments array would be ['-I', 'cisco.com']."`
cmd string `help:"The terminal command to be run, withouth the arguments. Ie: ping, whoami, curl."`
@ -29,7 +29,7 @@ type Settings struct {
// NewSettingsFromYAML loads the cmdrunner portion of the WTF config
func NewSettingsFromYAML(name string, moduleConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, moduleConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, moduleConfig, globalConfig),
args: utils.ToStrs(moduleConfig.UList("args")),
cmd: moduleConfig.UString("cmd"),

View File

@ -29,7 +29,7 @@ type Widget struct {
// NewWidget creates a new instance of the widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
buffer: &bytes.Buffer{},

View File

@ -32,15 +32,16 @@ type summary struct {
}
type Settings struct {
*cfg.Common
colors
common *cfg.Common
summary
}
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),
}
settings.colors.base.name = ymlConfig.UString("colors.base.name")

View File

@ -31,7 +31,7 @@ type Widget struct {
// NewWidget Make new instance of widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
summaryList: summaryList{},

View File

@ -17,8 +17,9 @@ type colors struct {
}
type Settings struct {
*cfg.Common
colors
common *cfg.Common
deviceToken string
displayHoldings bool
@ -27,7 +28,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),
deviceToken: ymlConfig.UString("device_token"),
displayHoldings: ymlConfig.UBool("displayHoldings", true),

View File

@ -20,7 +20,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
device_token: settings.deviceToken,
settings: settings,

View File

@ -38,15 +38,16 @@ type currency struct {
}
type Settings struct {
*cfg.Common
colors
common *cfg.Common
currencies map[string]*currency
}
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),
}
settings.colors.from.name = ymlConfig.UString("colors.from.name")

View File

@ -35,8 +35,9 @@ type colors struct {
}
type Settings struct {
*cfg.Common
colors
common *cfg.Common
currencies map[string]interface{}
top map[string]interface{}
@ -50,7 +51,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
top, _ := ymlConfig.Map("top")
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
currencies: currencies,
top: top,

View File

@ -39,15 +39,16 @@ type currency struct {
}
type Settings struct {
*cfg.Common
colors
common *cfg.Common
top map[string]*currency
top map[string]*currency
}
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),
}
settings.colors.from.name = ymlConfig.UString("colors.from.name")

View File

@ -22,7 +22,7 @@ type Widget struct {
// NewWidget Make new instance of widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
priceWidget: price.NewWidget(settings.priceSettings),
toplistWidget: toplist.NewWidget(settings.toplistSettings),

View File

@ -13,7 +13,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your Datadog API key."`
applicationKey string `help:"Your Datadog Application key."`
@ -23,7 +23,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_DATADOG_API_KEY"))),
applicationKey: ymlConfig.UString("applicationKey", os.Getenv("WTF_DATADOG_APPLICATION_KEY")),

View File

@ -19,7 +19,7 @@ type Widget struct {
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),
settings: settings,
}
@ -78,7 +78,7 @@ func (widget *Widget) content() (string, string, bool) {
" %s\n",
fmt.Sprintf(
"[%s]Triggered Monitors[white]",
widget.settings.common.Colors.Subheading,
widget.settings.Colors.Subheading,
),
)
for idx, triggeredMonitor := range triggeredMonitors {

View File

@ -13,7 +13,7 @@ const (
// Settings defines the configuration options for this module
type Settings struct {
common *cfg.Common
*cfg.Common
numberOfArticles int `help:"Number of stories to show. Default is 10" optional:"true"`
contentTag string `help:"List articles from a specific tag. Default is empty" optional:"true"`
@ -24,7 +24,8 @@ type Settings struct {
// NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated
func NewSettingsFromYAML(name string, yamlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, yamlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, yamlConfig, globalConfig),
numberOfArticles: yamlConfig.UInt("numberOfArticles", 10),
contentTag: yamlConfig.UString("contentTag", ""),
contentUsername: yamlConfig.UString("contentUsername", ""),

View File

@ -21,7 +21,7 @@ type Widget struct {
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),
settings: settings,
}

View File

@ -12,7 +12,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
color string `help:"The color of the clock."`
font string `help:"The font of the clock." values:"bigfont or digitalfont"`
@ -23,7 +23,7 @@ type Settings struct {
// 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),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
color: ymlConfig.UString("color"),
font: ymlConfig.UString("font"),

View File

@ -16,7 +16,7 @@ type Widget struct {
// NewWidget creates a new widget using settings
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
app: app,
settings: settings,

View File

@ -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)

View File

@ -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)),

View File

@ -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,

View File

@ -41,13 +41,13 @@ func (widget *Widget) getSystemInfo() string {
}{
{
name: "name:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.Name),
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, info.Name),
}, {
name: "version:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.ServerVersion),
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, info.ServerVersion),
}, {
name: "root:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.DockerRootDir),
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, info.DockerRootDir),
},
{
name: "containers:",
@ -57,15 +57,15 @@ func (widget *Widget) getSystemInfo() string {
},
{
name: "images:",
value: fmt.Sprintf("[%s]%d", widget.settings.common.Colors.RowTheme.EvenForeground, info.Images),
value: fmt.Sprintf("[%s]%d", widget.settings.Colors.RowTheme.EvenForeground, info.Images),
},
{
name: "volumes:",
value: fmt.Sprintf("[%s]%v", widget.settings.common.Colors.RowTheme.EvenForeground, len(diskUsage.Volumes)),
value: fmt.Sprintf("[%s]%v", widget.settings.Colors.RowTheme.EvenForeground, len(diskUsage.Volumes)),
},
{
name: "memory limit:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, humanize.Bytes(uint64(info.MemTotal))),
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, humanize.Bytes(uint64(info.MemTotal))),
},
{
name: "disk usage:",
@ -76,19 +76,19 @@ func (widget *Widget) getSystemInfo() string {
[%s]* [::b]total: [%s]%s[::-]
`,
widget.settings.labelColor,
widget.settings.common.Colors.RowTheme.EvenForeground,
widget.settings.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duContainer)),
widget.settings.labelColor,
widget.settings.common.Colors.RowTheme.EvenForeground,
widget.settings.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duImg)),
widget.settings.labelColor,
widget.settings.common.Colors.RowTheme.EvenForeground,
widget.settings.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duVol)),
widget.settings.labelColor,
widget.settings.common.Colors.RowTheme.EvenForeground,
widget.settings.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duContainer+duImg+duVol))),
},
}

View File

@ -12,14 +12,15 @@ const (
// Settings defines the configuration options for this module
type Settings struct {
common *cfg.Common
*cfg.Common
labelColor string
}
// NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated
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),
labelColor: ymlConfig.UString("labelColor", "white"),
}

View File

@ -18,7 +18,7 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, pages, settings.common),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
settings: settings,
}
@ -56,11 +56,11 @@ func (widget *Widget) refreshDisplayBuffer() {
widget.displayBuffer = ""
widget.displayBuffer += fmt.Sprintf("[%s] System[white]\n", widget.settings.common.Colors.Subheading)
widget.displayBuffer += fmt.Sprintf("[%s] System[white]\n", widget.settings.Colors.Subheading)
widget.displayBuffer += widget.getSystemInfo()
widget.displayBuffer += "\n"
widget.displayBuffer += fmt.Sprintf("[%s] Containers[white]\n", widget.settings.common.Colors.Subheading)
widget.displayBuffer += fmt.Sprintf("[%s] Containers[white]\n", widget.settings.Colors.Subheading)
widget.displayBuffer += widget.getContainerStates()
}

View File

@ -13,7 +13,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
precision int `help:"How many decimal places to display." optional:"true"`
@ -24,7 +24,7 @@ type Settings struct {
// 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),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
precision: ymlConfig.UInt("precision", 7),

View File

@ -20,7 +20,7 @@ type Widget struct {
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),
settings: settings,
}

View File

@ -13,7 +13,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
feeds []string `help:"An array of RSS and Atom feed URLs"`
feedLimit int `help:"The maximum number of stories to display for each feed"`
@ -22,7 +22,7 @@ type Settings struct {
// 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),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
feeds: utils.ToStrs(ymlConfig.UList("feeds")),
feedLimit: ymlConfig.UInt("feedLimit", -1),

View File

@ -65,7 +65,7 @@ func getShowText(feedItem *FeedItem, showType ShowType) string {
// 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),
parser: gofeed.NewParser(),
settings: settings,
@ -165,7 +165,7 @@ func (widget *Widget) content() (string, string, bool) {
// Grays out viewed items in the list, while preserving background highlighting when selected
rowColor = "gray"
if idx == widget.Selected {
rowColor = fmt.Sprintf("gray:%s", widget.settings.common.Colors.RowTheme.HighlightedBackground)
rowColor = fmt.Sprintf("gray:%s", widget.settings.Colors.RowTheme.HighlightedBackground)
}
}

View File

@ -15,7 +15,8 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your finnhub API token."`
symbols []string `help:"An array of stocks symbols (i.e. AAPL, MSFT)"`
}
@ -24,7 +25,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_FINNHUB_API_KEY"))),
symbols: utils.ToStrs(ymlConfig.UList("symbols")),

View File

@ -20,7 +20,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
Client: NewClient(settings.symbols, settings.apiKey),
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
}

View File

@ -13,7 +13,8 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your Football-data API token."`
league string `help:"Name of the competition. For example PL"`
favTeam string `help:"Teams to follow in mentioned league"`
@ -25,7 +26,8 @@ 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_FOOTBALL_API_KEY"))),
league: ymlConfig.UString("league", ymlConfig.UString("league", os.Getenv("WTF_FOOTBALL_LEAGUE"))),
favTeam: ymlConfig.UString("favTeam", ymlConfig.UString("favTeam", os.Getenv("WTF_FOOTBALL_TEAM"))),

View File

@ -51,7 +51,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
}
widget = Widget{
TextWidget: view.NewTextWidget(app, pages, settings.common),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
Client: NewClient(settings.apiKey),
League: leagueId,
settings: settings,

View File

@ -14,7 +14,7 @@ func (widget *Widget) display() {
}
func (widget *Widget) content() (string, string, bool) {
title := widget.settings.common.Title
title := widget.settings.Title
calEvents := widget.calEvents
if widget.err != nil {

View File

@ -21,25 +21,25 @@ func Test_display_content(t *testing.T) {
}{
{
name: "Event content without any events",
settings: &Settings{common: &cfg.Common{}},
settings: &Settings{Common: &cfg.Common{}},
events: nil,
descriptionWanted: "No calendar events",
},
{
name: "Event content with a single event, without end times displayed",
settings: &Settings{common: &cfg.Common{}, showEndTime: false},
settings: &Settings{Common: &cfg.Common{}, showEndTime: false},
events: []*CalEvent{NewCalEvent(event)},
descriptionWanted: "[]Saturday, Apr 19\n []01:00 []Foo[white]\n \n",
},
{
name: "Event content with a single event without showEndTime explictily set in settings",
settings: &Settings{common: &cfg.Common{}},
settings: &Settings{Common: &cfg.Common{}},
events: []*CalEvent{NewCalEvent(event)},
descriptionWanted: "[]Saturday, Apr 19\n []01:00 []Foo[white]\n \n",
},
{
name: "Event content with a single event with end times displayed",
settings: &Settings{common: &cfg.Common{}, showEndTime: true},
settings: &Settings{Common: &cfg.Common{}, showEndTime: true},
events: []*CalEvent{NewCalEvent(event)},
descriptionWanted: "[]Saturday, Apr 19\n []01:00-02:00 []Foo[white]\n \n",
},

View File

@ -23,7 +23,7 @@ type colors struct {
// Settings defines the configuration options for this module
type Settings struct {
colors
common *cfg.Common
*cfg.Common
conflictIcon string `help:"The icon displayed beside calendar events that have conflicting times (they intersect or overlap in some way)." values:"Any displayable unicode character." optional:"true"`
currentIcon string `help:"The icon displayed beside the current calendar event." values:"Any displayable unicode character." optional:"true"`
@ -44,7 +44,7 @@ type Settings struct {
// NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated
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),
conflictIcon: ymlConfig.UString("conflictIcon", "🚨"),
currentIcon: ymlConfig.UString("currentIcon", "🔸"),
@ -62,8 +62,9 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
calendarReadLevel: ymlConfig.UString("calendarReadLevel", "writer"),
}
settings.colors.day = ymlConfig.UString("colors.day", settings.common.Colors.Subheading)
settings.colors.day = ymlConfig.UString("colors.day", settings.Colors.Subheading)
settings.colors.description = ymlConfig.UString("colors.description", "white")
// settings.colors.eventTime is a new feature introduced via issue #638. Prior to this, the color of the event
// time was (unintentionally) customized via settings.colors.description. To maintain backwards compatibility
// for users who might be already using this to set the color of the event time, we try to determine the default
@ -72,6 +73,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
//
// PS: We should have a deprecation plan for supporting this backwards compatibility feature.
settings.colors.eventTime = ymlConfig.UString("colors.eventTime", settings.colors.description)
settings.colors.highlights = ymlConfig.UList("colors.highlights")
settings.colors.past = ymlConfig.UString("colors.past", "gray")
settings.colors.title = ymlConfig.UString("colors.title", "white")

View File

@ -16,7 +16,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
app: app,
settings: settings,

View File

@ -22,14 +22,14 @@ func (widget *Widget) content() (string, string, bool) {
title = fmt.Sprintf("%s- %s", widget.CommonSettings().Title, widget.title(project))
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.PaginationMarker(len(widget.GerritProjects), widget.Idx, width) + "\n"
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.common.Colors.Subheading)
str := widget.settings.PaginationMarker(len(widget.GerritProjects), widget.Idx, width) + "\n"
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.Colors.Subheading)
str += widget.displayStats(project)
str += "\n"
str += fmt.Sprintf(" [%s]Open Incoming Reviews[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" [%s]Open Incoming Reviews[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyIncomingReviews(project, widget.settings.username)
str += "\n"
str += fmt.Sprintf(" [%s]My Outgoing Reviews[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" [%s]My Outgoing Reviews[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyOutgoingReviews(project, widget.settings.username)
return title, str, false
@ -72,10 +72,10 @@ func (widget *Widget) displayStats(project *GerritProject) string {
func (widget *Widget) rowColor(idx int) string {
if widget.View.HasFocus() && (idx == widget.selected) {
return widget.settings.common.DefaultFocusedRowColor()
return widget.settings.DefaultFocusedRowColor()
}
return widget.settings.common.RowColor(idx)
return widget.settings.RowColor(idx)
}
func (widget *Widget) title(project *GerritProject) string {

View File

@ -21,7 +21,7 @@ type colors struct {
type Settings struct {
colors
common *cfg.Common
*cfg.Common
domain string `help:"Your Gerrit corporate domain."`
password string `help:"Your Gerrit HTTP Password."`
@ -32,7 +32,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),
domain: ymlConfig.UString("domain", ""),
password: ymlConfig.UString("password", os.Getenv("WTF_GERRIT_PASSWORD")),

View File

@ -31,7 +31,7 @@ var (
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
Idx: 0,

View File

@ -23,8 +23,8 @@ func (widget *Widget) content() (string, string, bool) {
)
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.PaginationMarker(len(widget.GitRepos), widget.Idx, width) + "\n"
str += fmt.Sprintf(" [%s]Branch[white]\n", widget.settings.common.Colors.Subheading)
str := widget.settings.PaginationMarker(len(widget.GitRepos), widget.Idx, width) + "\n"
str += fmt.Sprintf(" [%s]Branch[white]\n", widget.settings.Colors.Subheading)
str += fmt.Sprintf(" %s", repoData.Branch)
str += "\n"
str += widget.formatChanges(repoData.ChangedFiles)
@ -35,7 +35,7 @@ func (widget *Widget) content() (string, string, bool) {
}
func (widget *Widget) formatChanges(data []string) string {
str := fmt.Sprintf(" [%s]Changed Files[white]\n", widget.settings.common.Colors.Subheading)
str := fmt.Sprintf(" [%s]Changed Files[white]\n", widget.settings.Colors.Subheading)
if len(data) == 1 {
str += " [grey]none[white]\n"
@ -72,7 +72,7 @@ func (widget *Widget) formatChange(line string) string {
}
func (widget *Widget) formatCommits(data []string) string {
str := fmt.Sprintf(" [%s]Recent Commits[white]\n", widget.settings.common.Colors.Subheading)
str := fmt.Sprintf(" [%s]Recent Commits[white]\n", widget.settings.Colors.Subheading)
for _, line := range data {
str += widget.formatCommit(line)

View File

@ -12,7 +12,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
commitCount int `help:"The number of past commits to display." values:"A positive integer, 0..n." optional:"true"`
commitFormat string `help:"The string format for the commit message." optional:"true"`
@ -22,7 +22,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),
commitCount: ymlConfig.UInt("commitCount", 10),
commitFormat: ymlConfig.UString("commitFormat", "[forestgreen]%h [white]%s [grey]%an on %cd[white]"),

View File

@ -30,8 +30,8 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"),
TextWidget: view.NewTextWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
app: app,
pages: pages,

View File

@ -35,21 +35,21 @@ func (widget *Widget) content() (string, string, bool) {
}
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.PaginationMarker(len(widget.GithubRepos), widget.Idx, width)
str := widget.settings.PaginationMarker(len(widget.GithubRepos), widget.Idx, width)
if widget.settings.showStats {
str += fmt.Sprintf("\n [%s]Stats[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf("\n [%s]Stats[white]\n", widget.settings.Colors.Subheading)
str += widget.displayStats(repo)
}
if widget.settings.showOpenReviewRequests {
str += fmt.Sprintf("\n [%s]Open Review Requests[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf("\n [%s]Open Review Requests[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyReviewRequests(repo, username)
}
if widget.settings.showMyPullRequests {
str += fmt.Sprintf("\n [%s]My Pull Requests[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf("\n [%s]My Pull Requests[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyPullRequests(repo, username)
}
for _, customQuery := range widget.settings.customQueries {
str += fmt.Sprintf("\n [%s]%s[white]\n", widget.settings.common.Colors.Subheading, customQuery.title)
str += fmt.Sprintf("\n [%s]%s[white]\n", widget.settings.Colors.Subheading, customQuery.title)
str += widget.displayCustomQuery(repo, customQuery.filter, customQuery.perPage)
}
@ -139,7 +139,7 @@ func (widget *Widget) displayStats(repo *Repo) string {
func (widget *Widget) title(repo *Repo) string {
return fmt.Sprintf(
"[%s]%s - %s[white]",
widget.settings.common.Colors.TextTheme.Title,
widget.settings.Colors.TextTheme.Title,
repo.Owner,
repo.Name,
)

View File

@ -14,7 +14,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your GitHub API token."`
baseURL string `help:"Your GitHub Enterprise API URL." optional:"true"`
@ -37,7 +37,7 @@ type customQuery struct {
// 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),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_GITHUB_TOKEN"))),
baseURL: ymlConfig.UString("baseURL", os.Getenv("WTF_GITHUB_BASE_URL")),

View File

@ -25,8 +25,8 @@ type Widget struct {
// NewWidget creates a new instance of the widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"),
TextWidget: view.NewTextWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
settings: settings,
}

View File

@ -39,20 +39,20 @@ func (widget *Widget) content() (string, string, bool) {
title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.title(project))
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.PaginationMarker(len(widget.GitlabProjects), widget.Idx, width) + "\n"
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.common.Colors.Subheading)
str := widget.settings.PaginationMarker(len(widget.GitlabProjects), widget.Idx, width) + "\n"
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.Colors.Subheading)
str += widget.displayStats(project)
str += "\n"
str += fmt.Sprintf(" [%s]Open Assigned Merge Requests[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" [%s]Open Assigned Merge Requests[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyAssignedMergeRequests(project, widget.settings.username)
str += "\n"
str += fmt.Sprintf(" [%s]My Merge Requests[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" [%s]My Merge Requests[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyMergeRequests(project, widget.settings.username)
str += "\n"
str += fmt.Sprintf(" [%s]Open Assigned Issues[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" [%s]Open Assigned Issues[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyAssignedIssues(project, widget.settings.username)
str += "\n"
str += fmt.Sprintf(" [%s]My Issues[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" [%s]My Issues[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyIssues(project, widget.settings.username)
return title, str, false

View File

@ -14,7 +14,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"A GitLab personal access token. Requires at least api access."`
domain string `help:"Your GitLab corporate domain."`
@ -25,7 +25,7 @@ type Settings struct {
// 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),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_GITLAB_TOKEN"))),
domain: ymlConfig.UString("domain", "https://gitlab.com"),

View File

@ -33,8 +33,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
context, err := newContext(settings)
widget := Widget{
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"),
TextWidget: view.NewTextWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
context: context,
settings: settings,

View File

@ -13,7 +13,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
numberOfTodos int `help:"Defines number of stories to be displayed. Default is 10" optional:"true"`
apiKey string `help:"A GitLab personal access token. Requires at least api access."`
@ -24,7 +24,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),
numberOfTodos: ymlConfig.UInt("numberOfTodos", 10),
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_GITLAB_TOKEN")),

View File

@ -20,7 +20,7 @@ type Widget struct {
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),
settings: settings,
}

View File

@ -13,7 +13,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiToken string `help:"Your Gitter Personal Access Token."`
numberOfMessages int `help:"Maximum number of (newest) messages to be displayed. Default is 10" optional:"true"`
@ -23,7 +23,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),
apiToken: ymlConfig.UString("apiToken", os.Getenv("WTF_GITTER_API_TOKEN")),
numberOfMessages: ymlConfig.UInt("numberOfMessages", 10),

View File

@ -19,7 +19,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),
settings: settings,
}

View File

@ -11,7 +11,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
months int
secretFile string `help:"Your Google client secret JSON file." values:"A string representing a file path to the JSON secret file."`
@ -22,7 +22,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),
months: ymlConfig.UInt("months"),
secretFile: ymlConfig.UString("secretFile"),

View File

@ -13,7 +13,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
}

View File

@ -15,7 +15,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your Grafana API token."`
baseURI string `help:"Base url of your grafana instance"`
@ -24,7 +24,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", os.Getenv("WTF_GRAFANA_API_KEY")),
baseURI: ymlConfig.UString("baseUri", ""),

View File

@ -22,7 +22,7 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
Client: NewClient(settings),
Selected: -1,

View File

@ -16,7 +16,7 @@ type colors struct {
type Settings struct {
colors
common *cfg.Common
*cfg.Common
cellAddresses []interface{}
cellNames []interface{}
@ -27,7 +27,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),
cellNames: ymlConfig.UList("cells.names"),
secretFile: ymlConfig.UString("secretFile"),

View File

@ -19,7 +19,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
}

View File

@ -11,7 +11,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
numberOfStories int `help:"Defines number of stories to be displayed. Default is 10" optional:"true"`
storyType string `help:"Category of story to see" values:"new, top, job, ask" optional:"true"`
@ -20,7 +20,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),
numberOfStories: ymlConfig.UInt("numberOfStories", 10),
storyType: ymlConfig.UString("storyType", "top"),

View File

@ -20,7 +20,7 @@ type Widget struct {
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),
settings: settings,
}

View File

@ -23,7 +23,7 @@ type colors struct {
// Settings defines the configuration properties for this module
type Settings struct {
colors
common *cfg.Common
*cfg.Common
accounts []string `help:"A list of the accounts to check the HIBP database for."`
apiKey string `help:"Your HIBP API v3 API key"`
@ -33,7 +33,7 @@ type Settings struct {
// 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),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_HIBP_TOKEN"))),
accounts: utils.ToStrs(ymlConfig.UList("accounts")),
@ -47,8 +47,8 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
// HIBP data doesn't need to be reloaded very often so to be gentle on this API we
// enforce a minimum refresh interval
if settings.common.RefreshInterval < minRefreshInterval {
settings.common.RefreshInterval = minRefreshInterval
if settings.RefreshInterval < minRefreshInterval {
settings.RefreshInterval = minRefreshInterval
}
return settings

View File

@ -19,7 +19,7 @@ type Widget struct {
// NewWidget creates a new instance of a widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := &Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
}

View File

@ -17,13 +17,13 @@ type colors struct {
type Settings struct {
colors
common *cfg.Common
*cfg.Common
}
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),
}
settings.colors.name = ymlConfig.UString("colors.name", "red")

View File

@ -38,7 +38,7 @@ type ipinfo struct {
// NewWidget constructor
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
}

View File

@ -11,12 +11,12 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
}
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),
}
return &settings

View File

@ -32,7 +32,7 @@ type ipinfo struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
}
@ -96,8 +96,8 @@ func (widget *Widget) setResult(info *ipinfo) {
resultBuffer := new(bytes.Buffer)
err := resultTemplate.Execute(resultBuffer, map[string]string{
"subheadingColor": widget.settings.common.Colors.Subheading,
"valueColor": widget.settings.common.Colors.Text,
"subheadingColor": widget.settings.Colors.Subheading,
"valueColor": widget.settings.Colors.Text,
"Ip": info.Ip,
"Hostname": info.Hostname,
"City": info.City,

View File

@ -13,7 +13,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your Jenkins API key."`
jobNameRegex string `help:"A regex that filters the jobs shown in the widget." optional:"true"`
@ -26,7 +26,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_JENKINS_API_KEY"))),
jobNameRegex: ymlConfig.UString("jobNameRegex", ".*"),

View File

@ -19,7 +19,7 @@ type Widget struct {
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),
settings: settings,
}

View File

@ -21,7 +21,7 @@ type colors struct {
type Settings struct {
colors
common *cfg.Common
*cfg.Common
apiKey string `help:"Your Jira API key (or password for basic auth)."`
domain string `help:"Your Jira corporate domain."`
@ -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_JIRA_API_KEY"))),
domain: ymlConfig.UString("domain"),

View File

@ -18,7 +18,7 @@ type Widget struct {
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),
settings: settings,
}
@ -74,7 +74,7 @@ func (widget *Widget) content() (string, string, bool) {
title := widget.CommonSettings().Title
str := fmt.Sprintf(" [%s]Assigned Issues[white]\n", widget.settings.common.Colors.Subheading)
str := fmt.Sprintf(" [%s]Assigned Issues[white]\n", widget.settings.Colors.Subheading)
if widget.result == nil || len(widget.result.Issues) == 0 {
return title, "No results to display", false

View File

@ -12,7 +12,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
objects []string `help:"Kubernetes objects to show. Options are: [nodes, pods, deployments]."`
title string `help:"Override the title of widget."`
@ -24,7 +24,7 @@ type Settings struct {
func NewSettingsFromYAML(name string, moduleConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, moduleConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, moduleConfig, globalConfig),
objects: utils.ToStrs(moduleConfig.UList("objects")),
title: moduleConfig.UString("title"),

View File

@ -25,7 +25,7 @@ type Widget struct {
// NewWidget creates a new instance of the widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
objects: settings.objects,
title: settings.title,
@ -58,7 +58,7 @@ func (widget *Widget) Refresh() {
widget.Redraw(func() (string, string, bool) { return title, "[red] Error getting node data [white]\n", true })
return
}
content += fmt.Sprintf("[%s]Nodes[white]\n", widget.settings.common.Colors.Subheading)
content += fmt.Sprintf("[%s]Nodes[white]\n", widget.settings.Colors.Subheading)
for _, node := range nodeList {
content += fmt.Sprintf("%s\n", node)
}
@ -71,7 +71,7 @@ func (widget *Widget) Refresh() {
widget.Redraw(func() (string, string, bool) { return title, "[red] Error getting deployment data [white]\n", true })
return
}
content += fmt.Sprintf("[%s]Deployments[white]\n", widget.settings.common.Colors.Subheading)
content += fmt.Sprintf("[%s]Deployments[white]\n", widget.settings.Colors.Subheading)
for _, deployment := range deploymentList {
content += fmt.Sprintf("%s\n", deployment)
}
@ -84,7 +84,7 @@ func (widget *Widget) Refresh() {
widget.Redraw(func() (string, string, bool) { return title, "[red] Error getting pod data [white]\n", false })
return
}
content += fmt.Sprintf("[%s]Pods[white]\n", widget.settings.common.Colors.Subheading)
content += fmt.Sprintf("[%s]Pods[white]\n", widget.settings.Colors.Subheading)
for _, pod := range podList {
content += fmt.Sprintf("%s\n", pod)
}

View File

@ -11,12 +11,12 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
}
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),
}
return &settings

View File

@ -24,7 +24,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, nil, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.Common),
app: app,
filePath: log.LogFilePath(),

View File

@ -18,13 +18,13 @@ func (widget *Widget) content() (string, string, bool) {
title := fmt.Sprintf(
"%s - %s[white]",
widget.settings.common.Colors.TextTheme.Title,
widget.settings.Colors.TextTheme.Title,
repoData.Repository,
)
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.PaginationMarker(len(widget.Data), widget.Idx, width) + "\n"
str += fmt.Sprintf(" [%s]Branch:Bookmark[white]\n", widget.settings.common.Colors.Subheading)
str := widget.settings.PaginationMarker(len(widget.Data), widget.Idx, width) + "\n"
str += fmt.Sprintf(" [%s]Branch:Bookmark[white]\n", widget.settings.Colors.Subheading)
str += fmt.Sprintf(" %s:%s\n", repoData.Branch, repoData.Bookmark)
str += "\n"
str += widget.formatChanges(repoData.ChangedFiles)
@ -35,7 +35,7 @@ func (widget *Widget) content() (string, string, bool) {
}
func (widget *Widget) formatChanges(data []string) string {
str := fmt.Sprintf(" [%s]Changed Files[white]\n", widget.settings.common.Colors.Subheading)
str := fmt.Sprintf(" [%s]Changed Files[white]\n", widget.settings.Colors.Subheading)
if len(data) == 1 {
str += " [grey]none[white]\n"
@ -72,7 +72,7 @@ func (widget *Widget) formatChange(line string) string {
}
func (widget *Widget) formatCommits(data []string) string {
str := fmt.Sprintf(" [%s]Recent Commits[white]\n", widget.settings.common.Colors.Subheading)
str := fmt.Sprintf(" [%s]Recent Commits[white]\n", widget.settings.Colors.Subheading)
for _, line := range data {
str += widget.formatCommit(line)

View File

@ -11,7 +11,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
commitCount int `help:"The number of past commits to display." optional:"true"`
commitFormat string `help:"The string format for the commit message." optional:"true"`
@ -21,7 +21,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),
commitCount: ymlConfig.UInt("commitCount", 10),
commitFormat: ymlConfig.UString("commitFormat", "[forestgreen]{rev}:{phase} [white]{desc|firstline|strip} [grey]{author|person} {date|age}[white]"),

View File

@ -27,8 +27,8 @@ type Widget struct {
// NewWidget creates a new instance of a widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"),
TextWidget: view.NewTextWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
app: app,
pages: pages,

View File

@ -11,12 +11,12 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
}
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),
}
return &settings

View File

@ -26,7 +26,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{
TextWidget: view.NewTextWidget(app, pages, settings.common),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
settings: settings,
}
@ -73,7 +73,7 @@ func (widget *Widget) nbascore() (string, string, bool) {
return title, err.Error(), true
}
allGame := fmt.Sprintf(" [%s]", widget.settings.common.Colors.Subheading) + (cur.Format(utils.FriendlyDateFormat) + "\n\n") + "[white]"
allGame := fmt.Sprintf(" [%s]", widget.settings.Colors.Subheading) + (cur.Format(utils.FriendlyDateFormat) + "\n\n") + "[white]"
for _, game := range result["games"].([]interface{}) {
vTeam, hTeam, vScore, hScore := "", "", "", ""

View File

@ -39,7 +39,7 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string {
" %s\n",
fmt.Sprintf(
"[%s]Latest Deploys[white]",
widget.settings.common.Colors.Subheading,
widget.settings.Colors.Subheading,
),
)

View File

@ -13,7 +13,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your New Relic API token."`
deployCount int `help:"The number of past deploys to display on screen." optional:"true"`
@ -23,7 +23,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", os.Getenv("WTF_NEW_RELIC_API_KEY")),
deployCount: ymlConfig.UInt("deployCount", 5),

View File

@ -19,8 +19,8 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "applicationID", "applicationIDs"),
TextWidget: view.NewTextWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "applicationID", "applicationIDs"),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
settings: settings,
}

View File

@ -13,7 +13,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your OpsGenie API token."`
region string `help:"Defines region to use. Possible options: us (by default), eu." optional:"true"`
@ -25,7 +25,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_OPS_GENIE_API_KEY"))),
region: ymlConfig.UString("region", "us"),

Some files were not shown because too many files have changed in this diff Show More