From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9801 invoked from network); 30 Sep 2006 21:34:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 Sep 2006 21:34:34 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 75113 invoked from network); 30 Sep 2006 21:34:28 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Sep 2006 21:34:28 -0000 Received: (qmail 29284 invoked by alias); 30 Sep 2006 21:34:26 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22797 Received: (qmail 29275 invoked from network); 30 Sep 2006 21:34:25 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 30 Sep 2006 21:34:25 -0000 Received: (qmail 74715 invoked from network); 30 Sep 2006 21:34:25 -0000 Received: from acolyte.scowler.net (216.254.112.45) by a.mx.sunsite.dk with SMTP; 30 Sep 2006 21:34:25 -0000 Received: by acolyte.scowler.net (Postfix, from userid 1000) id 6A14170055; Sat, 30 Sep 2006 17:34:24 -0400 (EDT) Date: Sat, 30 Sep 2006 17:34:24 -0400 From: Clint Adams To: zsh-workers@sunsite.dk Subject: PATCH: _fuse_arguments, _fuse_values Message-ID: <20060930213424.GA24624@scowler.net> Mail-Followup-To: zsh-workers@sunsite.dk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) Generic fuse completion support from R.Ramkumar. Index: Completion/Linux/Type/_fuse_arguments =================================================================== RCS file: Completion/Linux/Type/_fuse_arguments diff -N Completion/Linux/Type/_fuse_arguments --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Completion/Linux/Type/_fuse_arguments 30 Sep 2006 21:33:35 -0000 @@ -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 Index: Completion/Linux/Type/_fuse_values =================================================================== RCS file: Completion/Linux/Type/_fuse_values diff -N Completion/Linux/Type/_fuse_values --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Completion/Linux/Type/_fuse_values 30 Sep 2006 21:33:35 -0000 @@ -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