mirror of
https://github.com/x-motemen/ghq.git
synced 2026-09-10 07:26:27 -04:00
114 lines
4.4 KiB
Plaintext
114 lines
4.4 KiB
Plaintext
#compdef ghq ghq-dev
|
|
|
|
function _ghq () {
|
|
local context curcontext=$curcontext state line
|
|
declare -A opt_args
|
|
local ret=1
|
|
|
|
_arguments -C \
|
|
'(-h --help)'{-h,--help}'[show help]' \
|
|
'(-v --version)'{-v,--version}'[print the version]' \
|
|
'1: :__ghq_commands' \
|
|
'*:: :->args' \
|
|
&& ret=0
|
|
|
|
case $state in
|
|
(args)
|
|
case $words[1] in
|
|
(get|clone)
|
|
_arguments -C \
|
|
'(-u --update)'{-u,--update}'[Update local repository if cloned already]' \
|
|
'-p[Clone with SSH]' \
|
|
'--shallow[Do a shallow clone]' \
|
|
'(-l --look)'{-l,--look}'[Look after get]' \
|
|
'--vcs[Specify vcs backend for cloning]: :(git github codecommit svn subversion git-svn hg mercurial darcs pijul fossil bzr bazaar)' \
|
|
'(-s --silent)'{-s,--silent}'[Clone or update silently]' \
|
|
'--no-recursive[Prevent recursive fetching]' \
|
|
'--bare[Do a bare clone]' \
|
|
'(-b --branch)'{-b,--branch}'[Specify branch name]' \
|
|
'(-P --parallel)'{-P,--parallel}'[Import parallelly]' \
|
|
'--partial[Do a partial clone]: :(blobless treeless)' \
|
|
'(-)*:: :->null_state' \
|
|
&& ret=0
|
|
if (( ${words[(I)-u]} )) || (( ${words[(I)--update]} )); then
|
|
__ghq_all_repositories && ret=0
|
|
fi
|
|
;;
|
|
(list)
|
|
_arguments -C \
|
|
'(-e --exact)'{-e,--exact}'[Perform an exact match]' \
|
|
'--vcs[Specify vcs backend for matching]: :(git github codecommit svn subversion git-svn hg mercurial darcs pijul fossil bzr bazaar)' \
|
|
'(-p --full-path)'{-p,--full-path}'[Print full paths]' \
|
|
'--unique[Print unique subpaths]' \
|
|
'--bare[Query bare repositories]' \
|
|
'(-)*:: :->null_state' \
|
|
&& ret=0
|
|
;;
|
|
(root)
|
|
_arguments -C \
|
|
'--all[Show all roots]' \
|
|
'(-)*:: :->null_state' \
|
|
&& ret=0
|
|
;;
|
|
(create)
|
|
_arguments -C \
|
|
'--vcs[Specify vcs backend explicitly]: :(git github codecommit svn subversion git-svn hg mercurial darcs pijul fossil bzr bazaar)' \
|
|
'--bare[Create a bare repository]' \
|
|
'(-)*:: :->null_state' \
|
|
&& ret=0
|
|
;;
|
|
(rm)
|
|
_arguments -C \
|
|
'--dry-run[Do not remove actually]' \
|
|
'--bare[Remove a bare repository]' \
|
|
'(-)*: :__ghq_all_repositories' \
|
|
&& ret=0
|
|
;;
|
|
(migrate)
|
|
_arguments -C \
|
|
'-y[Skip confirmation prompt]' \
|
|
'--dry-run[Show what would happen without moving]' \
|
|
':repository directory:_directories' \
|
|
&& ret=0
|
|
;;
|
|
(help|h)
|
|
__ghq_commands && ret=0
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
return ret
|
|
}
|
|
|
|
__ghq_repositories () {
|
|
local -a _repos
|
|
_repos=( ${(@f)"$(_call_program repositories ghq list --unique)"} )
|
|
_describe -t repositories Repositories _repos
|
|
}
|
|
|
|
__ghq_all_repositories () {
|
|
local -a _repos
|
|
_repos=( ${(@f)"$(_call_program repositories ghq list)"} )
|
|
_describe -t repositories Repositories _repos
|
|
}
|
|
|
|
__ghq_commands () {
|
|
local -a _c
|
|
_c=(
|
|
'get:Clone/sync with a remote repository'
|
|
'clone:Clone/sync with a remote repository'
|
|
'list:List local repositories'
|
|
'rm:Remove local repository'
|
|
'create:Create a new repository'
|
|
'migrate:Migrate existing repository to ghq-managed directory'
|
|
"root:Show repositories' root"
|
|
'help:Show a list of commands or help for one command'
|
|
'h:Show a list of commands or help for one command'
|
|
)
|
|
|
|
_describe -t commands Commands _c
|
|
}
|
|
|
|
_ghq "$@"
|