github.com/halhenke/ghq@v0.8.1-0.20180207100234-7e68f823b46d/zsh/_ghq (about) 1 #compdef ghq 2 3 function _ghq () { 4 local context curcontext=$curcontext state line 5 declare -A opt_args 6 local ret=1 7 8 _arguments -C \ 9 '(-h --help)'{-h,--help}'[show help]' \ 10 '(-v --version)'{-v,--version}'[print the version]' \ 11 '1: :__ghq_commands' \ 12 '*:: :->args' \ 13 && ret=0 14 15 case $state in 16 (args) 17 case $words[1] in 18 (get) 19 _arguments -C \ 20 '(-u --update)'{-u,--update}'[Update local repository if cloned already]' \ 21 '(-)*:: :->null_state' \ 22 && ret=0 23 ;; 24 (list) 25 _arguments -C \ 26 '(-e --exact)'{-e,--exact}'[Perform an exact match]' \ 27 '(-p --full-path)'{-p,--full-path}'[Print full paths]' \ 28 '--unique[Print unique subpaths]' \ 29 '(-)*:: :->null_state' \ 30 && ret=0 31 ;; 32 (look) 33 _arguments -C \ 34 '1: :__ghq_repositories' \ 35 && ret=0 36 ;; 37 (help|h) 38 __ghq_commands && ret=0 39 ;; 40 esac 41 ;; 42 esac 43 44 return ret 45 } 46 47 __ghq_repositories () { 48 local -a _repos 49 _repos=( ${(@f)"$(_call_program repositories ghq list --unique)"} ) 50 _describe -t repositories Repositories _repos 51 } 52 53 __ghq_commands () { 54 local -a _c 55 _c=( 56 'get:Clone/sync with a remote repository' 57 'list:List local repositories' 58 'look:Look into a local repository' 59 'import:Bulk get repositories from stdin' 60 "root:Show repositories' root" 61 'help:Show a list of commands or help for one command' 62 ) 63 64 _describe -t commands Commands _c 65 } 66 67 _ghq "$@" 68