Files
fish-config/functions/dockup.fish
T
rootiest 859f14a6e9 feat(functions): tag CLASSIFICATION across functions/ and conf.d/
Audits every function's interaction with the C1-shadowed commands
(uses-shadow/bypasses-shadow) and general hazards (destructive,
network, blocking-prompt) per the CLASSIFICATION schema.

Delegated the initial mechanical sweep to agy, then reviewed every
file by hand: fixed a systemic double-blank-comment-line formatting
bug from the delegate pass, and corrected several judgment errors
found on review -- three false blocking-prompt tags where a fish
'read' was consuming piped input rather than waiting on a terminal
(open-url.fish, sbver.fish, play-media.fish, now untagged entirely),
a blocking-prompt tag on mkrep.fish despite its documented --yes
escape hatch, an untagged read in jobrunner.fish's own baseless
blocking-prompt claim (removed, along with a destructive tag on
cleanup of its own mktemp output -- the schema explicitly excludes
that), the same own-output-cleanup false positive on
_zellij_dump_log.fish's destructive tag, an interactive fzf-gated
confirmation on logs.fish and replay.fish's piped read misread the
same way as the first three, and a uses-shadow(mkdir) on mkcd.fish
that actually belongs to the _fish_mkdir_p helper it delegates to,
not to mkcd itself.
2026-09-21 21:26:44 -04:00

82 lines
2.4 KiB
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# CATEGORY
# 14-miscellaneous
#
# CLASSIFICATION
# network
#
# 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
__fish_palette
echo "$c_head""Usage:$c_reset $c_cmd""dockup$c_reset $c_arg""[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_arg""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