mirror of
https://github.com/x-motemen/ghq.git
synced 2026-09-10 15:36:19 -04:00
86 lines
2.5 KiB
Plaintext
86 lines
2.5 KiB
Plaintext
_ghq() {
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
local subcommands="get clone list root rm create migrate help"
|
|
local global_opts="--help -h"
|
|
|
|
if [[ $cword = 1 ]]; then
|
|
COMPREPLY=( $(compgen -W "$subcommands $global_opts --version -v" -- "$cur") )
|
|
return 0
|
|
fi
|
|
|
|
local vcs_backends="git github codecommit svn subversion git-svn hg mercurial darcs pijul fossil bzr bazaar"
|
|
|
|
case "${words[1]}" in
|
|
get|clone)
|
|
local opts="--update -u -p --shallow --look -l --vcs --silent -s --no-recursive --branch -b --parallel -P --bare --partial"
|
|
if [[ $cur = -* ]]; then
|
|
COMPREPLY=( $(compgen -W "$opts $global_opts" -- "$cur") )
|
|
return 0
|
|
fi
|
|
case "$prev" in
|
|
--branch|-b)
|
|
# expects branch name
|
|
;;
|
|
--partial)
|
|
COMPREPLY=( $(compgen -W "blobless treeless" -- "$cur") );;
|
|
--vcs)
|
|
COMPREPLY=( $(compgen -W "$vcs_backends" -- "$cur") );;
|
|
*)
|
|
local arg
|
|
for arg in "${words[@]}"; do
|
|
case "$arg" in
|
|
--update|-u)
|
|
COMPREPLY=( $(compgen -W "$(ghq list)" -- "$cur") )
|
|
break;;
|
|
esac
|
|
done;;
|
|
esac;;
|
|
list)
|
|
local opts="--exact -e --vcs --full-path -p --unique --bare"
|
|
if [[ $cur = -* ]]; then
|
|
COMPREPLY=( $(compgen -W "$opts $global_opts" -- "$cur") )
|
|
return 0
|
|
fi
|
|
case "$prev" in
|
|
--vcs)
|
|
COMPREPLY=( $(compgen -W "$vcs_backends" -- "$cur") );;
|
|
esac;;
|
|
root)
|
|
local opts="--all"
|
|
if [[ $cur = -* ]]; then
|
|
COMPREPLY=( $(compgen -W "$opts $global_opts" -- "$cur") )
|
|
return 0
|
|
fi;;
|
|
rm)
|
|
local opts="--dry-run --bare"
|
|
if [[ $cur = -* ]]; then
|
|
COMPREPLY=( $(compgen -W "$opts $global_opts" -- "$cur") )
|
|
return 0
|
|
fi
|
|
COMPREPLY=( $(compgen -W "$(ghq list)" -- "$cur") );;
|
|
create)
|
|
local opts="--vcs --bare"
|
|
if [[ $cur = -* ]]; then
|
|
COMPREPLY=( $(compgen -W "$opts $global_opts" -- "$cur") )
|
|
return 0
|
|
fi
|
|
case "$prev" in
|
|
--vcs)
|
|
COMPREPLY=( $(compgen -W "$vcs_backends" -- "$cur") );;
|
|
esac;;
|
|
migrate)
|
|
local opts="-y --dry-run"
|
|
if [[ $cur = -* ]]; then
|
|
COMPREPLY=( $(compgen -W "$opts $global_opts" -- "$cur") )
|
|
return 0
|
|
fi
|
|
_filedir -d;;
|
|
help)
|
|
COMPREPLY=( $(compgen -W "$subcommands $global_opts" -- "$cur") );;
|
|
esac
|
|
}
|
|
|
|
complete -F _ghq ghq
|