diff options
author | Clint Adams <clint@users.sourceforge.net> | 2006-09-30 21:39:16 +0000 |
---|---|---|
committer | Clint Adams <clint@users.sourceforge.net> | 2006-09-30 21:39:16 +0000 |
commit | a1ce5f21488c93303a1ff1bd303a92f03748ea88 (patch) | |
tree | fc3b59ecedec9b486a0c5a3f61d6d4b11abc8b7c | |
parent | 232c068f3cdea6bfa6a114a6596855d805e10d97 (diff) | |
download | zsh-a1ce5f21488c93303a1ff1bd303a92f03748ea88.tar.gz zsh-a1ce5f21488c93303a1ff1bd303a92f03748ea88.tar.xz zsh-a1ce5f21488c93303a1ff1bd303a92f03748ea88.zip |
22797: generic FUSE completion support functions.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | Completion/Linux/Type/_fuse_arguments | 53 | ||||
-rw-r--r-- | Completion/Linux/Type/_fuse_values | 70 |
3 files changed, 127 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index d0fb08067..f09f63a40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-09-30 Clint Adams <clint@zsh.org> + * 22797: R. Ramkumar: Completion/Linux/Type/_fuse_arguments, + Completion/Linux/Type/_fuse_values: generic FUSE completion + support functions. + * 22796: R. Ramkumar: Completion/Unix/Command/_subversion: fix misspelling of IPREFIX. diff --git a/Completion/Linux/Type/_fuse_arguments b/Completion/Linux/Type/_fuse_arguments new file mode 100644 index 000000000..ea705a2d0 --- /dev/null +++ b/Completion/Linux/Type/_fuse_arguments @@ -0,0 +1,53 @@ +#autoload + +local ret long rawret nm=${compstate[nmatches]} fsopt cvalsvar +typeset -a fargs opts + +fargs=( + '(-d -f)-d[enable debug output]' + '-f[enable foreground operation]' + '-r[mount filesystem read-only]' + '-s[disable multi-threaded operation]' + '(-h --help)'{-h,--help}'[display help and exit]' + '(-V --version)'{-V,--version}'[show version information and exit]' +) + +(( $# )) || fargs+='*:default: _default' + +long=$argv[(I)--] +if (( long )); then + argv[long]=($fargs --) +else + set -- $@ $fargs +fi + +while [[ $1 == -(O*|F*|[CRWsw]) ]]; do + if [[ $1 == -F?* ]]; then + cvalsvar=${1[3,-1]} + elif [[ $1 == -F ]]; then + cvalsvar=$2 + shift + else + opts+=$1 + [[ $1 == -R ]] && rawret=yes + fi + shift +done + +if [[ $cvalsvar != - ]]; then + fsopt='*-o[specify mount options]:mount option:_fuse_values' + [[ -n $cvalsvar ]] && fsopt+=" -A $cvalsvar" + fsopt+=' mount\ option' + set -- $@ $fsopt +fi + +_arguments -R $opts $@ + +ret=$? + +if [[ $ret == 300 ]]; then + compstate[restore]= + [[ -z $rawret ]] && ret=$(( nm == $compstate[nmatches] )) +fi + +return ret diff --git a/Completion/Linux/Type/_fuse_values b/Completion/Linux/Type/_fuse_values new file mode 100644 index 000000000..2600d141c --- /dev/null +++ b/Completion/Linux/Type/_fuse_values @@ -0,0 +1,70 @@ +#autoload + +local ret stateset fvals cvalsvar cvalind +typeset -a fvals opts + +if [[ $1 = -O* ]]; then + opts+=$1 + shift +fi +opts+=(-s , -S =) + +cvalind=$argv[(I)-A*] + +while (( cvalind )); do + if [[ ${(P)cvalind} = -A?* ]]; then + cvalsvar=${(P)cvalind[3,-1]} + argv[cvalind]=() + else + cvalsvar=$argv[cvalind+1] + argv[cvalind,cvalind+1]=() + fi + cvalind=$argv[(I)-A*] +done + +fvals=( + 'ro[mount filesystem read-only]' + 'allow_other[allow access to other users]' + 'allow_root[allow access to root]' + 'nonempty[allow mounts over non-empty file/dir]' + 'default_permissions[enable permission checking by kernel]' + 'fsname[set filesystem name]:name' + 'large_read[issue large read requests (linux v2.4 only)]' + 'max_read[set maximum size of read requests]:size' + 'hard_remove[immediate removal (do not hide files)]' + 'use_ino[let filesystem set inode numbers]' + 'readdir_ino[try to fill in d_ino in readdir]' + 'direct_io[use direct I/O]' + 'kernel_cache[cache files in kernel]' + 'umask[set file permissions]:permission mask (octal)' + 'uid[set file owner]:user id:' + 'gid[set file group]:group id:' + 'entry_timeout[cache timeout for names]:timeout (s)' + 'negative_timeout[cache timeout for deleted names]:timeout (s)' + 'attr_timeout[cache timeout for attributes]:timeout (s)' +) + +[[ -n $cvalsvar ]] && set -- $@ ${(P)cvalsvar} + +if [[ $# -eq 0 ]]; then + set -- 'mount options' $fvals +else + set -- $@ $fvals +fi + +if [[ -n $state ]]; then + stateset=$state + state= +fi + +_values $opts $@ && ret=0 + +if [[ -n $state ]]; then + compstate[restore]= +elif [[ -n $stateset ]]; then + state=$stateset +else + unset state +fi + +return $ret |