From 68c2d3ad42fbb009403052ab954ccd978f7b3280 Mon Sep 17 00:00:00 2001 From: dimonl Date: Wed, 20 Aug 2025 21:59:27 +0200 Subject: [PATCH] extract captions to const --- pkg/config/app_config.go | 9 +++++++-- pkg/gui/presentation/container_stats.go | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 9c0ad474..4abeb786 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -22,6 +22,11 @@ import ( "github.com/jesseduffield/yaml" ) +const ( + CPUCaption = "CPU (%)" + MemoryCaption = "Memory (%)" +) + // UserConfig holds all of the user-configurable options type UserConfig struct { // Gui is for configuring visual things like colors and whether we show or @@ -460,12 +465,12 @@ func GetDefaultConfig() UserConfig { MaxDuration: duration, Graphs: []GraphConfig{ { - Caption: "CPU (%)", + Caption: CPUCaption, StatPath: "DerivedStats.CPUPercentage", Color: "cyan", }, { - Caption: "Memory (%)", + Caption: MemoryCaption, StatPath: "DerivedStats.MemoryPercentage", Color: "green", }, diff --git a/pkg/gui/presentation/container_stats.go b/pkg/gui/presentation/container_stats.go index 27e20782..7806e1bb 100644 --- a/pkg/gui/presentation/container_stats.go +++ b/pkg/gui/presentation/container_stats.go @@ -93,14 +93,14 @@ func plotGraph(container *commands.Container, spec config.GraphConfig, width int memoryLimit := utils.FormatDecimalBytes(int(container.StatHistory[dataLength-1].DerivedStats.MemoryLimit)) var caption string switch spec.Caption { - case "CPU (%)": + case config.CPUCaption: caption = fmt.Sprintf( "%s: %0.2f (%v)", spec.Caption, data[dataLength-1], time.Since(container.StatHistory[0].RecordedAt).Round(time.Second), ) - case "Memory (%)": + case config.MemoryCaption: caption = fmt.Sprintf( "%s: %s / %s (%0.2f) (%v)", spec.Caption,