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