Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: minimal dropbox command line completion



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