Add the established c_head/c_cmd/c_flag/c_dim/c_arg color scheme to --help (or usage-on-error) output in play-media and 13 other functions that lacked it or used an ad hoc scheme: bkg, detach, replay, p, y, spark, wake-lock, open-url, repo-open, dng2avif, dockup, fish-deps (__fish_deps_help), and scrub. Also tweak the standard itself: - c_cmd now uses plain `set_color --bold` instead of `--bold white`, so the command name adapts to the terminal's foreground instead of forcing white text that washes out on light-background themes. Applied across all functions already using the pattern. - jobrunner's reset variable renamed from c_rst to c_reset to match the naming used everywhere else.
83 lines
2.5 KiB
Fish
83 lines
2.5 KiB
Fish
# Copyright (C) 2026 Rootiest
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
# CATEGORY
|
|
# 14-miscellaneous
|
|
#
|
|
# SYNOPSIS
|
|
# dockup [-h] [directory]
|
|
#
|
|
# DESCRIPTION
|
|
# Pulls the latest Docker images and restarts all services in a Docker Compose
|
|
# project, then prunes dangling images. Accepts an optional target directory.
|
|
#
|
|
# ARGUMENTS
|
|
# -h, --help Show help message
|
|
# directory Path to the compose project (defaults to current directory)
|
|
#
|
|
# EXIT STATUS
|
|
# 0 Services updated and running
|
|
# 1 Directory not found or no docker-compose.yml present
|
|
#
|
|
# EXAMPLE
|
|
# dockup ~/myapp
|
|
function dockup --description 'Pull and restart docker compose containers'
|
|
# Define colors
|
|
set -l clr_error (set_color red)
|
|
set -l clr_info (set_color -b blue white)
|
|
set -l clr_success (set_color green)
|
|
set -l clr_off (set_color normal)
|
|
|
|
# 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)
|
|
echo "$c_head""Usage:$c_reset $c_cmd""dockup$c_reset $c_dim""[DIRECTORY]$c_reset"
|
|
echo ""
|
|
echo "$c_head""Options:$c_reset"
|
|
echo " $c_flag-h$c_reset, $c_flag--help$c_reset Show this help message"
|
|
echo ""
|
|
echo "$c_head""Arguments:$c_reset"
|
|
echo " $c_dim""DIRECTORY$c_reset Optional path to the compose project (defaults to current dir)"
|
|
return 0
|
|
end
|
|
|
|
# Handle directory navigation
|
|
if count $argv >/dev/null
|
|
set -l target_dir $argv[1]
|
|
if test -d $target_dir
|
|
pushd $target_dir >/dev/null
|
|
else
|
|
echo $clr_error"Error: Directory '$target_dir' not found."$clr_off
|
|
return 1
|
|
end
|
|
end
|
|
|
|
# Check for compose file
|
|
if not test -f docker-compose.yml -o -f docker-compose.yaml
|
|
echo $clr_error"Error: No docker-compose.yml found in "(pwd)$clr_off
|
|
if count $argv >/dev/null
|
|
popd >/dev/null
|
|
end
|
|
return 1
|
|
end
|
|
|
|
# Execution
|
|
echo $clr_info" UPDATING "$clr_off" Containers in "(set_color -o)(pwd)$clr_off"..."
|
|
|
|
if docker compose pull && docker compose up -d --remove-orphans
|
|
echo $clr_success"✔ Upgrade complete!"$clr_off
|
|
docker image prune -f
|
|
else
|
|
echo $clr_error"✘ Upgrade failed."$clr_off
|
|
end
|
|
|
|
# Cleanup directory state
|
|
if count $argv >/dev/null
|
|
popd >/dev/null
|
|
end
|
|
end
|