res-theme: non-interactive apply mode (res-theme apply) #15
Labels
No labels
harness
proj-core-console
proj-core-demo
proj-core-edit
proj-core-init
proj-core-lib
proj-core-login
proj-core-res
proj-core-sh
proj-core-theme
proj-docs
proj-extra-calc
proj-extra-code
proj-extra-playbook
proj-extra-sheets
proj-harness
proj-os
residual
tier-0-trivial
tier-1-easy
tier-2-medium
tier-3-hard
tier-4-major
tier-5-epic
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
residual/.agent#15
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
res-themecurrently only runs as an interactive TUI editor for the theme config. Add a non-interactive mode so it can be called from scripts,.bashrc, session starters, and cron jobs to apply the current theme to the terminal.Design
CLI interface
res-theme applytheme.LoadConfig()(follows the normal waterfall: defaults →/etc→~/.config)theme.InitTheme(cfg)to populate the package-level palette variablestheme.ApplyConsolePalette(os.Stdout)— safe for shell sessionstheme.ApplyPalette(os.Stdout)with a--fullflagThe default behavior (
applywithout--full) usesApplyConsolePalette(fg/bg only) because that's what's safe for general shell use — remapping all 16 ANSI colors would break child process colors.res-theme resetCall
theme.ResetPalette(os.Stdout)and exit.Flags
--full— useApplyPalette(full 16-color remap) instead ofApplyConsolePalette(fg/bg only). Only applies toapply.Non-interactive detection
When args are present (
apply,reset), skip the bubbletea TUI entirely and go straight to the OSC emit path. This avoids the alt-screen setup cost and keeps the terminal clean.Files to change
core/cmd/res-theme/main.goapplyandresetsubcommands short-circuit to OSC emitVerification
go build ./cmd/res-theme/go vet ./cmd/res-theme/res-theme applyin a terminal → should see fg/bg change to amberres-theme reset→ should restore terminal defaultsres-theme(no args) → should launch interactive TUI as beforego test ./...still passesNotes
ApplyPalette,ApplyConsolePalette,ResetPalette). This is just wiring a CLI entry point to it.theme.LoadConfig()already handles the waterfall.res-theme applyto session startup docs (e.g.docs/init-design.mdor a newdocs/theme.md).Implemented non-interactive
applyandresetsubcommands:res-theme apply— loads config, emits OSC 10/11 (fg/bg), exitsres-theme apply --full— loads config, emits OSC 4 (full 16-color remap), exitsres-theme reset— emits reset OSC, exitsres-theme(no args) — launches interactive TUI as beforeBuild and tests pass.