API-CLI
view release on metacpan or search on metacpan
examples/bash/githubcl.bash view on Meta::CPAN
#!bash
# http://stackoverflow.com/questions/7267185/bash-autocompletion-add-description-for-possible-completions
_githubcl() {
COMPREPLY=()
local program=githubcl
local cur=${COMP_WORDS[$COMP_CWORD]}
# echo "COMP_CWORD:$COMP_CWORD cur:$cur" >>/tmp/comp
declare -a FLAGS
declare -a OPTIONS
declare -a MYWORDS
local INDEX=`expr $COMP_CWORD - 1`
MYWORDS=("${COMP_WORDS[@]:1:$COMP_CWORD}")
FLAGS=('--debug' 'debug' '-d' 'debug' '--verbose' 'verbose' '-v' 'verbose' '--help' 'Show command help' '-h' 'Show command help')
OPTIONS=('--data-file' 'File with data for POST/PUT/PATCH/DELETE requests')
__githubcl_handle_options_flags
case $INDEX in
0)
__comp_current_options || return
__githubcl_dynamic_comp 'commands' 'DELETE'$'\t''DELETE call'$'\n''GET'$'\t''GET call'$'\n''PATCH'$'\t''PATCH call'$'\n''POST'$'\t''POST call'$'\n''PUT'$'\t''PUT call'$'\n''help'$'\t''Show command help'
;;
*)
# subcmds
case ${MYWORDS[0]} in
DELETE)
FLAGS+=()
OPTIONS+=()
__githubcl_handle_options_flags
case $INDEX in
1)
__comp_current_options || return
__githubcl_dynamic_comp 'commands' '/gists/:id'$'\t''Delete a gist.'$'\n''/gists/:id/comments/:commentId'$'\t''Delete a comment.'$'\n''/gists/:id/star'$'\t''Unstar a gist.'$'\n''/notifications/threads/:id/subscription'$'\t''Delete a Threa...
;;
*)
# subcmds
case ${MYWORDS[1]} in
/gists/:id)
FLAGS+=()
OPTIONS+=()
__githubcl_handle_options_flags
case $INDEX in
2)
__comp_current_options || return
;;
*)
__comp_current_options true || return # after parameters
case ${MYWORDS[$INDEX-1]} in
--data-file)
;;
esac
;;
esac
;;
/gists/:id/comments/:commentId)
FLAGS+=()
OPTIONS+=()
__githubcl_handle_options_flags
case $INDEX in
2)
__comp_current_options || return
;;
3)
__comp_current_options || return
;;
*)
__comp_current_options true || return # after parameters
case ${MYWORDS[$INDEX-1]} in
--data-file)
( run in 0.371 second using v1.01-cache-2.11-cpan-0bd6704ced7 )