AutoYADM commit: 2025-04-29 14:00:05

This commit is contained in:
Daniel Fichtinger 2025-04-29 14:00:06 -04:00
parent 7e0e1db700
commit 90fef97ba4

View file

@ -1,38 +1,57 @@
function update --description "Update everything" function update --description "Update everything"
# autoconfirm
argparse y/no-confirm -- $argv
# TODO: add configuration options and publish? # TODO: add configuration options and publish?
sudo -v
set -l termcmd foot fish -c set -l termcmd foot fish -c
set -l lines 'cargo install-update -a set -l std 'cargo install-update -a
gup update gup update
uv tool upgrade --all uv tool upgrade --all '
flatpak update -y set -l noconfirm 'flatpak update -y
yes | paru -Syu' yes | paru -Syu'
set -l cmds (string split \n -- $lines | string trim) set -l confirm 'flatpak update
paru -Syu'
set -l cmds (string split \n -- $std | string trim)
if set -q _flag_y
set --append cmds $noconfirm
sudo -v
else
set --append cmds $confirm
end
echo Commands to be run: echo Commands to be run:
for i in $cmds for i in $cmds
echo $i echo $i
end end
return 0
function execute -a cmds
argparse i/interactive -- $argv
if set -ql _flag_i
for cmd in $cmds
# max 2 jobs at a time
while test (count (jobs -p)) -ge 2
sleep 0.5
end
if string match -q "*paru *" -- "$cmd"
eval $cmd
else
$termcmd $cmd &>/dev/null &
end
end
else
for cmd in $cmds
eval $cmd
end
end
end
if isatty stdin; and isatty stdout if isatty stdin; and isatty stdout
while read --nchars 1 -l response --prompt-str="Run on multiple terminals? (y/n)" or return 1 while read --nchars 1 -l response --prompt-str="Run on multiple terminals? (y/n)" or return 1
switch $response switch $response
case y Y case y Y
for cmd in $cmds execute --interactive $cmds
# max 2 jobs at a time
while test (count (jobs -p)) -ge 2
sleep 0.5
end
if string match -q "*paru *" -- "$cmd"
eval $cmd
else
$termcmd $cmd &>/dev/null &
end
end
wait wait
break break
case n N case n N
for cmd in $cmds execute $cmds
eval $cmd
end
break break
case '*' case '*'
echo Invalid input! echo Invalid input!
@ -40,8 +59,6 @@ yes | paru -Syu'
end end
end end
else else
for cmd in $cmds execute $cmds
eval $cmd
end
end end
end end