diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-16 23:03:53 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-16 23:03:53 +0200 |
| commit | 41e25da4ccb3121ee9d22f8e9ad48568241d897c (patch) | |
| tree | 2bd05c5cd5bc1fb7c52238037c647ca52015038f /internal/config | |
| parent | 0f35a55c0ca2beef550d7a3fb425c53ea7b5ce88 (diff) | |
Add toggleable host separator lines (hotkey s)
Draw 1px yellow vertical lines between hosts when monitoring multiple
servers, making it easy to see where one host's bars end and the next
begins. Toggled with hotkey 's', persisted via 'w' to ~/.loadbarsrc.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/config')
| -rw-r--r-- | internal/config/config.go | 11 | ||||
| -rw-r--r-- | internal/config/config_test.go | 37 |
2 files changed, 45 insertions, 3 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index d53fd7f..1b4c9e1 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -28,8 +28,9 @@ type Config struct { ShowIOAvgLine bool ShowCores bool ShowMem bool - ShowNet bool - SSHOpts string + ShowNet bool + ShowSeparators bool + SSHOpts string Cluster string } @@ -106,7 +107,8 @@ func (c *Config) parseReader(f *os.File) error { "title": true, "barwidth": true, "cpuaverage": true, "extended": true, "hasagent": true, "height": true, "maxwidth": true, "netaverage": true, "netlink": true, "showcores": true, "showmem": true, - "showavgline": true, "showioavgline": true, "shownet": true, "sshopts": true, "cluster": true, + "showavgline": true, "showioavgline": true, "shownet": true, "showseparators": true, + "sshopts": true, "cluster": true, } scanner := bufio.NewScanner(f) for scanner.Scan() { @@ -171,6 +173,8 @@ func (c *Config) set(key, val string) { c.ShowMem = parseBool(val) case "shownet": c.ShowNet = parseBool(val) + case "showseparators": + c.ShowSeparators = parseBool(val) case "sshopts": c.SSHOpts = val case "cluster": @@ -207,6 +211,7 @@ func (c *Config) writeTo(f *os.File) error { writeBool("showcores", c.ShowCores) writeBool("showmem", c.ShowMem) writeBool("shownet", c.ShowNet) + writeBool("showseparators", c.ShowSeparators) writeStr("sshopts", c.SSHOpts) writeStr("cluster", c.Cluster) return w.Flush() diff --git a/internal/config/config_test.go b/internal/config/config_test.go index a8535be..630fa47 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -152,6 +152,43 @@ func TestConfig_showIOAvgLineRoundTrip(t *testing.T) { } } +func TestConfig_showSeparatorsRoundTrip(t *testing.T) { + // Write a config with showseparators=1, read it back, verify round-trip + c := Default() + c.ShowSeparators = true + + dir := t.TempDir() + path := filepath.Join(dir, "rc") + f, err := os.Create(path) + if err != nil { + t.Fatal(err) + } + if err := c.writeTo(f); err != nil { + f.Close() + t.Fatal(err) + } + f.Close() + + data, _ := os.ReadFile(path) + if !bytes.Contains(data, []byte("showseparators=1")) { + t.Errorf("expected showseparators=1 in output, got:\n%s", data) + } + + // Read it back + c2 := Default() + f2, err := os.Open(path) + if err != nil { + t.Fatal(err) + } + defer f2.Close() + if err := c2.parseReader(f2); err != nil { + t.Fatal(err) + } + if !c2.ShowSeparators { + t.Error("expected ShowSeparators=true after round-trip") + } +} + func TestGetClusterHostsFromFile(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "clusters") |
