Re: [PATCH 2/2] completion: Use parse-options raw output for simple long options
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Apr 11, 2012, 13:09 UTC
- Message-ID
- <20120411130924.GD3161@burratino>
- In-Reply-To
- <1334140165-24958-3-git-send-email-bebarino@gmail.com>
Stephen Boyd wrote:
> Is there some way to compute these lists with some magical function instead > of duplicating that logic over and over?
Maybe roughly like this.
for command in $porcelain
do
eval "__git_${command//-/_}_options="
done
__git_complete_for_command ()
{
local options
local options_var="__git_${command//-/_}_options"eval "options=\$$options_var" if test -z "$options" then eval "$options_var=\$(__git_list_command_options \$command)" eval "options=\$$options_var" fi
... }
_git () {
...
__git_complete_for_command "$command"
}Jonathan