Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: minimal dropbox command line completion
- X-seq: zsh-workers 47342
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: PATCH: minimal dropbox command line completion
- Date: Fri, 28 Aug 2020 02:22:32 +0000
- Archived-at: <https://zsh.org/workers/47342>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-08/20200828022232.0914170c%40tarpaulin.shahaf.local2>
- Authentication-results: zsh.org; iprev=pass (out3-smtp.messagingengine.com) smtp.remote-ip=66.111.4.27; dkim=pass header.d=daniel.shahaf.name header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=skipped; arc=none
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding; s=fm1; bh=iLZey2UvpY75Bb3D1Njb03N2gB pj1ALjza4blZ5eyIQ=; b=yMkY1hYgslIUiUqI1rDG+tA6Jhmajs5IXufOQY2QqG dH+S9jbjtTAgKqU4+uRvqUlu2yJUopPBoCMJTEwVacE/FrAMwxH7Aqn5kmcpjv43 reQldr3FxM9p3b00OHLyau/o57ljcERRM0zzwSSZWUG9ahUNZAVhUQiv0K7NS226 31/QXis6c/zszyxuH0VSEkbOYC4g52hMt6zw714vZvgSQJcty04v/kL7LHiTRPWr str1FGFZhSJfdvP3IkycMahO5AXxh3d/liRnddOazdQJuWCtLsfLBfD0J9kd0KJI FMYOVFrNZsBLKah1t/wo4Y1r8QerbHXGB+AhQM4Hvlug==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=iLZey2UvpY75Bb3D1Njb03N2gBpj1ALjza4blZ5ey IQ=; b=n7ZBGnZ9wc60EjYaYEa0nnVUgNVzW+CwlTXjdbybDtjzzvXcZAoa+pN94 Vq1ZPwxSatCpffM675zHh33ZSxs/81CDcyt76fRxUE4AuTpHpBIGIw8LihiJNKJl DVncsXqcLUeZ9HAZt+fcc1PyfdN/jSMauhSxqPMAYGNzTXlGI3fwG5QacVyzu5KT DL0LrLpQAWKUgwNMj5prLY6CNZNv+clqpYx74hvLn1cb7PJS0iGmthNhwvh2aEkn d+KtLgOyC9ZAI01zax48h5/Nr2dxENlsFsa1moWNHLiuV/Z9Pujz1CRgW+PTACGI fHPDtf+H87eodLFhE+Ses70XDSU4Q==
- In-reply-to: <ee24c5f032cd407c4677b670fc297f7152868ed8.camel@ntlworld.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- References: <ee24c5f032cd407c4677b670fc297f7152868ed8.camel@ntlworld.com>
- Sender: zsh-workers-request@xxxxxxx
Peter Stephenson wrote on Thu, 27 Aug 2020 21:15 +0100:
> +++ b/Completion/Unix/Command/_dropbox
Relation to [1]? It uses a different top-of-file directive, but
nevertheless seems to be possibly related.
[1] https://github.com/zpm-zsh/dropbox/blob/master/functions/_dropbox-cli
[2] https://github.com/ivoarch/dropbox-zsh-completion/blob/master/_dropbox
> @@ -0,0 +1,16 @@
> +#compdef dropbox
> +
> +if [[ CURRENT -eq 2 || $words[2] = help ]]; then
> + local -a line progs
> +
> + _call_program commands command dropbox help |
> + while read -A line; do
> + if [[ $line[1] = [a-z]## ]]; then
> + progs+=("$line[1]:$line[2,-1]")
Suggest s/$line[1]/${line[1]}/ for forward compatibility with
a potential future «:$» history modifier. (And -r to 'read')
> + fi
> + done
> +
> + _describe -t dropbox-commands 'Dropbox command' progs
> +elif [[ $words[2] = (ls|filestatus|sharelink) ]]; then
> + _files
else
return 1
> +fi
>
>
Aside: I wonder why we don't use a «_call_completion_function()
{ readonly -i n=$compstate[nmatches]; "$@" && (( $compstate[nmatches] > $n)) }»
wrapper around calls to $_comps[foo]: that'd save every single
completion function having to manage $ret explicitly.)
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author