Skip to content

Commit 7bac764

Browse files
author
linux_name2
committed
feat: add shell completions for atomic-upgrade
1 parent 182bc79 commit 7bac764

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎Makefile‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ install:
4242
$(DESTDIR)$(ZSH_COMPDIR)/_atomic-gc
4343
install -Dm644 completions/_atomic-rebuild-uki \
4444
$(DESTDIR)$(ZSH_COMPDIR)/_atomic-rebuild-uki
45+
install -Dm644 completions/_atomic-upgrade \
46+
$(DESTDIR)$(ZSH_COMPDIR)/_atomic-upgrade
4547
install -Dm644 completions/atomic-gc.bash \
4648
$(DESTDIR)$(BASH_COMPDIR)/atomic-gc
4749
install -Dm644 completions/atomic-rebuild-uki.bash \
4850
$(DESTDIR)$(BASH_COMPDIR)/atomic-rebuild-uki
51+
install -Dm644 completions/atomic-upgrade.bash \
52+
$(DESTDIR)$(BASH_COMPDIR)/atomic-upgrade
4953

5054
install -Dm644 hooks/00-block-direct-upgrade.hook \
5155
$(DESTDIR)$(HOOKSDIR)/00-block-direct-upgrade.hook
@@ -73,8 +77,10 @@ uninstall:
7377
rm -rf $(DESTDIR)$(LIBDIR)/
7478
rm -f $(DESTDIR)$(ZSH_COMPDIR)/_atomic-gc
7579
rm -f $(DESTDIR)$(ZSH_COMPDIR)/_atomic-rebuild-uki
80+
rm -f $(DESTDIR)$(ZSH_COMPDIR)/_atomic-upgrade
7681
rm -f $(DESTDIR)$(BASH_COMPDIR)/atomic-gc
7782
rm -f $(DESTDIR)$(BASH_COMPDIR)/atomic-rebuild-uki
83+
rm -f $(DESTDIR)$(BASH_COMPDIR)/atomic-upgrade
7884
rm -f $(DESTDIR)$(HOOKSDIR)/00-block-direct-upgrade.hook
7985
rm -f $(DESTDIR)$(PREFIX)/local/bin/pacman
8086
rm -f $(DESTDIR)$(MANDIR)/man8/atomic-upgrade.8

‎completions/_atomic-upgrade‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#compdef atomic-upgrade
2+
3+
_atomic-upgrade() {
4+
_arguments \
5+
'(- *)'{-h,--help}'[Show help]' \
6+
'(- *)'{-V,--version}'[Show version]' \
7+
'(-n --dry-run)'{-n,--dry-run}'[Show what would be done]' \
8+
'(-t --tag)'{-t,--tag}'[Custom tag for snapshot]:tag:' \
9+
'--no-gc[Skip garbage collection]' \
10+
'--separate-home[Create isolated /home subvolume (requires --tag)]' \
11+
'--copy-files[Copy files into new home]:file list:' \
12+
'(-)--[Command separator]' \
13+
'*:command:_command_names'
14+
}
15+
16+
_atomic-upgrade "$@"

‎completions/atomic-upgrade.bash‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# bash completion for atomic-upgrade
2+
3+
_atomic_upgrade() {
4+
local cur prev words cword
5+
_init_completion || return
6+
7+
local i has_dashdash=0
8+
for ((i=1; i < cword; i++)); do
9+
[[ "${words[i]}" == "--" ]] && { has_dashdash=1; break; }
10+
done
11+
12+
if [[ $has_dashdash -eq 1 ]]; then
13+
COMPREPLY=( $(compgen -c -- "$cur") )
14+
return
15+
fi
16+
17+
case "$prev" in
18+
-t|--tag|--copy-files) return ;;
19+
esac
20+
21+
if [[ "$cur" == -* ]]; then
22+
COMPREPLY=( $(compgen -W "-h --help -V --version -n --dry-run -t --tag --no-gc --separate-home --copy-files --" -- "$cur") )
23+
fi
24+
}
25+
26+
complete -F _atomic_upgrade atomic-upgrade

0 commit comments

Comments
 (0)