-
-
Save 3tty0n/0ef541bb9fce758c4c064ce96ba83a91 to your computer and use it in GitHub Desktop.
completion for gol in zsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#compdef gol | |
function _gol { | |
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]' \ | |
'--datapath [/path/to/data/file (default: "~/.config/gol/links.json")]' \ | |
'1: :__gol_commands' \ | |
'*:: :->args' \ | |
&& ret=0 | |
case $state in | |
(args) | |
case $words[1] in | |
(open) | |
_arguments -C\ | |
'1: :__gol_keys' \ | |
&& ret=0 | |
;; | |
(rm) | |
_arguments -C\ | |
'1: :__gol_keys' \ | |
&& ret=0 | |
;; | |
(help|h) | |
__gol_commands && ret=0 | |
;; | |
(*) | |
ret=0 | |
;; | |
esac | |
;; | |
esac | |
return ret | |
} | |
function __gol_keys { | |
local -a _keys | |
_keys=( ${(@f)"$(_call_program keys gol ls)"} ) | |
_describe -t keys Keys _keys | |
} | |
function __gol_commands { | |
local -a _c | |
_c=( | |
'add:add the key' | |
'rm:remove the key' | |
'ls:display keys' | |
'get:get the key' | |
'dump:run dump' | |
'open:open the key' | |
'peco:open the key in peco' | |
'server:start the gol server' | |
) | |
_describe -t commands Commands _c | |
} | |
_gol "$@" | |
compdef _gol gol |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment