dotcli: install subcommand as wrapper for pacman

The install subcommand also manages a list of packages intalled
through `dot install`. This list can be restored using `dot install
--restore`.
This commit is contained in:
2026-07-04 09:38:22 -04:00
parent 80581f5029
commit d41e1c46f4
5 changed files with 193 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
function _dot_install
argparse 'restore' 'no-sync' -- $argv
or return 1
set -l list_dir $HOME/.config/dot/packages
set -l list_file $list_dir/pacman
set -l packages
if set -q _flag_restore
if test (count $argv) -gt 0
echo "dot install: --restore cannot be combined with package names" >&2
return 1
end
if not test -s $list_file
echo "dot install: no package list found at $list_file" >&2
return 1
end
set packages (cat $list_file)
else
if test (count $argv) -eq 0
echo "dot install: no packages given (use --restore to reinstall from the list)" >&2
return 1
end
set packages $argv
end
if not set -q _flag_no_sync
sudo pacman -Sy
or return 1
end
sudo pacman -S --needed $packages
or return 1
if set -q _flag_restore
return 0
end
mkdir -p $list_dir
test -f $list_file
or touch $list_file
printf '%s\n' $packages >>$list_file
sort -u -o $list_file $list_file
end