man: Add option parsing and completion.
This commit is contained in:
parent
3998a70dd9
commit
efeb1a22dd
@ -4,16 +4,48 @@
|
|||||||
_man()
|
_man()
|
||||||
{
|
{
|
||||||
local cur prev words cword
|
local cur prev words cword
|
||||||
_init_completion -n : || return
|
_init_completion -n := || return
|
||||||
|
|
||||||
|
local split=false
|
||||||
|
_split_longopt && split=true
|
||||||
|
|
||||||
local i sect manpath manext mansect uname
|
local i sect manpath manext mansect uname
|
||||||
|
|
||||||
manext="@([0-9lnp]|[0-9][px]|man|3pm)?(.@([gx]z|bz2|lzma|Z))"
|
manext="@([0-9lnp]|[0-9][px]|man|3pm)?(.@([gx]z|bz2|lzma|Z))"
|
||||||
mansect="@([0-9lnp]|[0-9][px]|3pm)"
|
mansect="@([0-9lnp]|[0-9][px]|3pm)"
|
||||||
|
|
||||||
if [[ "$prev" == -l ]]; then
|
case $prev in
|
||||||
_filedir $manext
|
-C|--config-file)
|
||||||
return 0
|
_filedir conf
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
-l|--local-file)
|
||||||
|
_filedir $manext
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
-M|--manpath)
|
||||||
|
_filedir -d
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
-P|--pager)
|
||||||
|
COMPREPLY=( $( compgen -c -- "$cur" ) )
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
-p|--preprocessor)
|
||||||
|
COMPREPLY=( $( compgen -W 'e p t g r v' -- "$cur" ) )
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
-L|--locale|-m|--systems|-e|--extension|-r|--prompt|-R|--recode|\
|
||||||
|
-E|--encoding)
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
$split && return
|
||||||
|
|
||||||
|
if [[ $cur == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) )
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_expand || return 0
|
_expand || return 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user