Skip to content

Commit

Permalink
completions: add Fish completions
Browse files Browse the repository at this point in the history
closes #6
  • Loading branch information
triallax authored and classabbyamp committed Apr 13, 2023
1 parent 8550331 commit a5d67fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ install: all
install -Dm 755 xmirror -t $(DESTDIR)$(PREFIX)/bin
install -Dm 644 mirrors.lst -t $(DESTDIR)$(PREFIX)/share/xmirror
install -Dm 644 completions/_xmirror -t $(DESTDIR)$(PREFIX)/share/zsh/site-functions
install -Dm 644 completions/xmirror.fish -t $(DESTDIR)/$(PREFIX)/share/fish/vendor_completions.d
install -Dm 644 xmirror.1 -t $(DESTDIR)$(PREFIX)/share/man/man1

clean:
Expand Down
25 changes: 25 additions & 0 deletions completions/xmirror.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
complete -c xmirror -f

function __xmirror_complete_mirrors
string match -vr '^\s*#' </usr/share/xmirror/mirrors.lst | while read -l line
set -l values (string split \t -- $line)
# Mirror url, location, and tier
echo -- $values[2]\t$values[3], Tier $values[4]
end
end

function __xmirror_no_interactive_opts
not __fish_seen_argument -s l -l mirror-list -s n -l no-fetch
end

function __xmirror_no_noninteractive_opts
not __fish_seen_argument -s d -l default -s s -l set
end

complete -c xmirror -s h -l help -d 'Display help and exit'
complete -c xmirror -s v -l version -d 'Display version and exit'
complete -c xmirror -s r -l rootdir -d 'Use alternative rootdir' -xa '(__fish_complete_directories)'
complete -c xmirror -n '__xmirror_no_noninteractive_opts' -s l -l mirror-list -d 'Use alternative mirror list file' -rF
complete -c xmirror -n '__xmirror_no_noninteractive_opts' -s n -l no-fetch -d "Don't update mirror list"
complete -c xmirror -n '__xmirror_no_interactive_opts' -s d -l default -d 'Reset current mirror to default'
complete -c xmirror -n '__xmirror_no_interactive_opts' -s s -l set -d 'Set current mirror' -kxa '(__xmirror_complete_mirrors)'

0 comments on commit a5d67fa

Please sign in to comment.