From b0c6d7f7f5b65071da948a0b09e4e7d5768c5382 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 20:05:23 -0400 Subject: [PATCH] refactor: use __fish_palette in system and package functions 44 duplicated declarations replaced by 8 calls. Output strings untouched. fish-deps, upgrade and wake-lock have no --help path and are deliberately NOT added to the harness case list -- upgrade and wake-lock have side effects, and runtime coverage is not worth mutating state during tests. They are covered by --structural, which proves mechanically that no rendering line changed. --- functions/dockup.fish | 6 +----- functions/fish-deps.fish | 6 +----- functions/jobrunner.fish | 9 +-------- functions/kitty-logging.fish | 9 +-------- functions/pkg.fish | 9 +-------- functions/scrub.fish | 5 +---- functions/upgrade.fish | 3 +-- functions/wake-lock.fish | 5 +---- 8 files changed, 8 insertions(+), 44 deletions(-) diff --git a/functions/dockup.fish b/functions/dockup.fish index 2f2fbf8..97c78fe 100644 --- a/functions/dockup.fish +++ b/functions/dockup.fish @@ -30,11 +30,7 @@ function dockup --description 'Pull and restart docker compose containers' # Handle help flags if contains -- -h $argv; or contains -- --help $argv - set -l c_head (set_color --bold cyan) - set -l c_cmd (set_color --bold) - set -l c_flag (set_color yellow) - set -l c_dim (set_color brblack) - set -l c_reset (set_color normal) + __fish_palette echo "$c_head""Usage:$c_reset $c_cmd""dockup$c_reset $c_dim""[DIRECTORY]$c_reset" echo "" echo "$c_head""Options:$c_reset" diff --git a/functions/fish-deps.fish b/functions/fish-deps.fish index bf9839e..acf9aba 100644 --- a/functions/fish-deps.fish +++ b/functions/fish-deps.fish @@ -93,11 +93,7 @@ end # EXAMPLE # __fish_deps_help function __fish_deps_help - set -l c_head (set_color --bold cyan) - set -l c_cmd (set_color --bold) - set -l c_flag (set_color yellow) - set -l c_dim (set_color brblack) - set -l c_reset (set_color normal) + __fish_palette echo "$c_head""fish-deps$c_reset — manage fish shell dependencies" echo "" diff --git a/functions/jobrunner.fish b/functions/jobrunner.fish index 1fffdf6..9c5a24c 100644 --- a/functions/jobrunner.fish +++ b/functions/jobrunner.fish @@ -51,14 +51,7 @@ # redirections must be wrapped explicitly, e.g. # jobrunner run sync fish -c 'a | b'. function jobrunner --description 'Manage detached background jobs with tmux or GNU screen' - set -l c_head (set_color --bold cyan) - set -l c_cmd (set_color --bold) - set -l c_arg (set_color cyan) - set -l c_flag (set_color yellow) - set -l c_ok (set_color green) - set -l c_err (set_color red) - set -l c_dim (set_color brblack) - set -l c_reset (set_color normal) + __fish_palette set -l subcmds run list attach kill logs help \ -r --run -l --list -a --attach -k --kill -o --output -h --help diff --git a/functions/kitty-logging.fish b/functions/kitty-logging.fish index dbff8d9..82eb2bc 100644 --- a/functions/kitty-logging.fish +++ b/functions/kitty-logging.fish @@ -38,14 +38,7 @@ # kitty-logging install # kitty-logging status function kitty-logging --description 'Install/manage the fish-config Kitty scrollback watcher' - set -l c_head (set_color --bold cyan) - set -l c_cmd (set_color --bold) - set -l c_flag (set_color yellow) - set -l c_ok (set_color green) - set -l c_warn (set_color yellow) - set -l c_err (set_color red) - set -l c_dim (set_color brblack) - set -l c_reset (set_color normal) + __fish_palette set -l cmd $argv[1] diff --git a/functions/pkg.fish b/functions/pkg.fish index d7ba4c3..15f968d 100644 --- a/functions/pkg.fish +++ b/functions/pkg.fish @@ -46,14 +46,7 @@ function pkg --description 'Install or remove packages via the system package ma end # ── Colour palette ─────────────────────────────────────────── - set -l c_head (set_color --bold cyan) - set -l c_cmd (set_color --bold) - set -l c_flag (set_color yellow) - set -l c_ok (set_color green) - set -l c_warn (set_color yellow) - set -l c_err (set_color red) - set -l c_dim (set_color brblack) - set -l c_reset (set_color normal) + __fish_palette # ── Installed-check helper ─────────────────────────────────── # Uses only its own arguments — safe to define as an inner function. diff --git a/functions/scrub.fish b/functions/scrub.fish index 02a60cd..8670780 100644 --- a/functions/scrub.fish +++ b/functions/scrub.fish @@ -63,10 +63,7 @@ function scrub --description 'Recursively purge OS, editor, and compiler garbage # Helper function for help menu text function _scrub_help - set -l c_head (set_color --bold cyan) - set -l c_cmd (set_color --bold) - set -l c_flag (set_color yellow) - set -l c_reset (set_color normal) + __fish_palette echo "$c_head""Usage:$c_reset $c_cmd""scrub$c_reset $c_flag""[options]$c_reset" echo diff --git a/functions/upgrade.fish b/functions/upgrade.fish index 68702bb..38443de 100644 --- a/functions/upgrade.fish +++ b/functions/upgrade.fish @@ -23,8 +23,7 @@ function upgrade --description 'Full system upgrade via paru or yay' # Opinionated guard (C4): integrations disabled if not __fish_config_op_enabled (status current-function) - set -l c_err (set_color red) - set -l c_reset (set_color normal) + __fish_palette echo "$c_err"'upgrade: disabled by __fish_config_op_integrations'"$c_reset" >&2 return 1 end diff --git a/functions/wake-lock.fish b/functions/wake-lock.fish index 053556e..c71e44f 100644 --- a/functions/wake-lock.fish +++ b/functions/wake-lock.fish @@ -23,10 +23,7 @@ # wake-lock rsync -avz src/ dest/ function wake-lock --description 'Run a command while inhibiting system sleep' if test (count $argv) -eq 0 - set -l c_head (set_color --bold cyan) - set -l c_cmd (set_color --bold) - set -l c_arg (set_color cyan) - set -l c_reset (set_color normal) + __fish_palette echo "$c_head""Usage:$c_reset $c_cmd""wake-lock$c_reset $c_arg""[command] [args...]$c_reset" return 1 end