From 2530990230e2a7ccfbe6e6e69b401d0acd451759 Mon Sep 17 00:00:00 2001 From: Simon Whitaker Date: Tue, 12 Jun 2018 19:32:27 +0100 Subject: [PATCH] [v2] Update zsh tab completion script Closes #28 --- shell-completions/gibo-completion.zsh | 48 +++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/shell-completions/gibo-completion.zsh b/shell-completions/gibo-completion.zsh index ea57761..f6a08ef 100644 --- a/shell-completions/gibo-completion.zsh +++ b/shell-completions/gibo-completion.zsh @@ -17,11 +17,29 @@ # # fpath=(~/.zsh $fpath) # +# +# CONTRIBUTING +# +# See https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org +# for tips on writing and testing zsh completion functions. +# # CREDITS # # Written by Simon Whitaker -_gibo() +_gibo_commands() +{ + _gibo_commands=( + 'dump:Dump one or more boilerplates' \ + 'list:List available boilerplates' \ + 'update:Update list of available boilerplates' \ + 'help:Display this help text' \ + 'version:Display current script version' + ) + _describe 'command' _gibo_commands +} + +_gibo_dump_commands() { local local_repo=${GIBO_BOILERPLATES:-"$HOME/.gitignore-boilerplates"} local -a boilerplates @@ -29,10 +47,26 @@ _gibo() boilerplates=($local_repo/**/*.gitignore(:r:t)) fi - _arguments \ - {-l,--list}'[List available boilerplates]' \ - {-u,--upgrade}'[Upgrade list of available boilerplates]' \ - {-h,--help}'[Display this help text]' \ - {-v,--version}'[Display current script version]' \ - "*:boilerplate:($boilerplates)" + _arguments "*:boilerplate:($boilerplates)" +} + +_gibo() +{ + local ret=1 + + _arguments -C \ + '1: :_gibo_commands' \ + '*::arg:->args' \ + && ret=0 + + case $state in + args ) + case $line[1] in + dump ) + _arguments \ + '*: :_gibo_dump_commands' \ + && ret=0 + ;; + esac + esac }