1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#compdef dochelp
_dochelp-cat() {
_arguments \
':docid Document ID to print:_files'
}
_dochelp-info() {
_arguments \
':docid Document ID to print:_files'
}
_dochelp-search() {
_arguments \
':optional regexp:_files'
}
_dochelp-update() {
_arguments \
'::optional target:_files' \
'--online[Use relative paths in generated HTML page]'
}
_dochelp() {
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options' \
case $state in
(command)
#breaks if defined outside the func
local -a subcommands
subcommands=(
'cat:Dump the content of a document'
'info:Print available information about a document'
'list:List known registered documents'
'search:Look for matching documents'
'update:Print available information for a document'
)
_describe -t commands dochelp subcommands
;;
(options)
_arguments \
'--help[print a help message]' \
'--version[print version number]' \
'--base-doc[Specify doc-base directory]:directory:_path_files -/'
local funcname
funcname=_dochelp-$line[1]
if type $funcname | grep -q "shell function" ; then
$funcname
fi
;;
esac
}
_dochelp "$@"
|