I hacked together a bash completion file for rpa, and wanted to share.
You can find it at:
http://ruby.brian-schroeder.de/rpa-completion/
What it can
···
-----------
- Completion of commands, options and ports
What it is missing
------------------
- Completion of not downloaded ports.
I didn't find a rpa switch to list the known ports.
If someone has an idea, I could add it easily.
regards,
Brian
--
Brian Schröder
http://ruby.brian-schroeder.de/
I hacked together a bash completion file for rpa, and wanted to share.
Thanks a lot... I'm definitely adding it to /etc/bash_completion.d: I
use rpa quite often 
BTW, would it be OK to include it in the next release of rpa-base or
somewhere under http://rpa-base.rubyforge.org ?
You can find it at:
http://ruby.brian-schroeder.de/rpa-completion/
What it can
-----------
- Completion of commands, options and ports
What it is missing
------------------
- Completion of not downloaded ports.
I didn't find a rpa switch to list the known ports.
If someone has an idea, I could add it easily.
I tried it with GNU bash, version 3.00.0(1)-release (i386-pc-linux-gnu)
and it didn't like the 'have' magic, so I had to comment it out.
Please find attached a patch to allow completion of unknown ports and
discrimination between installed and available ports.
patch (1.69 KB)
···
On Tue, Oct 12, 2004 at 09:38:58AM +0900, Brian Schröder wrote:
--
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
Mauricio Fernández wrote:
I hacked together a bash completion file for rpa, and wanted to share.
Thanks a lot... I'm definitely adding it to /etc/bash_completion.d: I
use rpa quite often 
BTW, would it be OK to include it in the next release of rpa-base or
somewhere under http://rpa-base.rubyforge.org ?
Sure. Take it and use it. I included your patch.
Maybe you could update your description of the query option. I did not think that it could be used to display a list of all packages. (I only saw that it suggested using a port afterwards and thought it was to query information about a port.) But maybe I was only too fast asleep.
regards,
Brian
···
On Tue, Oct 12, 2004 at 09:38:58AM +0900, Brian Schröder wrote:
--
Brian Schröder
http://ruby.brian-schroeder.de/
Hi,
At Tue, 12 Oct 2004 21:20:31 +0900,
Mauricio Ferne.AeNandez wrote in [ruby-talk:116288]:
Please find attached a patch to allow completion of unknown ports and
discrimination between installed and available ports.
You forgot to change RPA_PORT_COMANDS for compgen.
And improvement for multiple package completion.
# Debian GNU/Linux rpa completion
# Made for "rpa (rpa-base 0.2.2-6) RPA 0.0"
···
# Copyright 2004 Brian Schre.AeNvder <mail@brian-schroeder.de>
# See http://ruby.brian-schroeder.de/ for the latest version.
# License: GNU LGPL v2 or later
_rpa() {
local cur prev cmd idx
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
RPA_SIMPLE_COMMANDS=(dist list update rollback clean help)
RPA_LOCAL_PORT_COMMANDS=(remove info check)
RPA_REMOTE_PORT_COMMANDS=(install build source query search)
RPA_PORT_COMMANDS=(${RPA_LOCAL_PORT_COMMANDS[*]} ${RPA_REMOTE_PORT_COMMANDS[*]})
RPA_OPTIONS=(-h --help --no-proxy --proxy -q --quiet -x --extended \
--verbose --debug -v --version \
-f --force -p --parallelize --no-tests -r --requires \
-c --classification -e -eval -D --eval-display)
idx=1
while [ $idx -lt $COMP_CWORD ]; do
case "${COMP_WORDS[idx]}" in
-*) ;;
*) prev="${COMP_WORDS[idx]}"; break;;
esac
idx=$[idx+1]
done
if [ ${prev+set} ]; then
case " ${RPA_SIMPLE_COMMANDS[*]} " in
*" $prev "*)
COMPREPLY=( $(compgen -W "${RPA_OPTIONS[*]}" ${cur}) );
return 0;;
esac
case " ${RPA_LOCAL_PORT_COMMANDS[*]} " in
*" $prev "*)
cmd=list;;
esac
case " ${RPA_REMOTE_PORT_COMMANDS[*]} " in
*" $prev "*)
cmd=query;;
esac
if [ "$cmd" ]; then
COMPREPLY=( $(compgen -W "$(rpa $cmd | ruby -n -e 'puts $1 if /([-\w]+)\s+[0-9]+/')" ${cur} ) )
else
COMPREPLY=( $(compgen -W "${RPA_SIMPLE_COMMANDS[*]} ${RPA_PORT_COMMANDS[*]} ${RPA_OPTIONS[*]}" ${cur} ) )
fi
fi
return 0
}
complete -F _rpa rpa
# 10/11/2004: First release
# 10/12/2004: Patch by Mauricio Ferne$BaOe(Bdez
--
Nobu Nakada
Mauricio Fernández wrote:
>
>>I hacked together a bash completion file for rpa, and wanted to share.
>
>
>Thanks a lot... I'm definitely adding it to /etc/bash_completion.d: I
>use rpa quite often 
>
>BTW, would it be OK to include it in the next release of rpa-base or
>somewhere under http://rpa-base.rubyforge.org ?
>
Sure. Take it and use it. I included your patch.
Great 
Maybe you could update your description of the query option. I did not
think that it could be used to display a list of all packages. (I only
saw that it suggested using a port afterwards and thought it was to
query information about a port.) But maybe I was only too fast asleep.
You are, of course, right. The command line interface can be made much
better and some steps towards that have already been taken in the 0.3
devel branch.
···
On Wed, Oct 13, 2004 at 04:08:53AM +0900, Brian Schröder wrote:
>On Tue, Oct 12, 2004 at 09:38:58AM +0900, Brian Schröder wrote:
--
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
Thanks for the patch. As soon as I have tested it I'll put it up. I guess thats a complete rewrite, there is not much left of what I put in 
I have to admit that I hate shell syntax.
regards,
Brian
···
On Tue, 19 Oct 2004 11:54:55 +0900 nobu.nokada@softhome.net wrote:
Hi,
At Tue, 12 Oct 2004 21:20:31 +0900,
Mauricio Ferne.AeNandez wrote in [ruby-talk:116288]:
> Please find attached a patch to allow completion of unknown ports and
> discrimination between installed and available ports.
You forgot to change RPA_PORT_COMANDS for compgen.
And improvement for multiple package completion.
# Debian GNU/Linux rpa completion
# Made for "rpa (rpa-base 0.2.2-6) RPA 0.0"
# Copyright 2004 Brian Schre.AeNvder <mail@brian-schroeder.de>
# See http://ruby.brian-schroeder.de/ for the latest version.
# License: GNU LGPL v2 or later
_rpa() {
local cur prev cmd idx
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
RPA_SIMPLE_COMMANDS=(dist list update rollback clean help)
RPA_LOCAL_PORT_COMMANDS=(remove info check)
RPA_REMOTE_PORT_COMMANDS=(install build source query search)
RPA_PORT_COMMANDS=(${RPA_LOCAL_PORT_COMMANDS[*]} ${RPA_REMOTE_PORT_COMMANDS[*]})
RPA_OPTIONS=(-h --help --no-proxy --proxy -q --quiet -x --extended \
--verbose --debug -v --version \
-f --force -p --parallelize --no-tests -r --requires \
-c --classification -e -eval -D --eval-display)
idx=1
while [ $idx -lt $COMP_CWORD ]; do
case "${COMP_WORDS[idx]}" in
-*) ;;
*) prev="${COMP_WORDS[idx]}"; break;;
esac
idx=$[idx+1]
done
if [ ${prev+set} ]; then
case " ${RPA_SIMPLE_COMMANDS[*]} " in
*" $prev "*)
COMPREPLY=( $(compgen -W "${RPA_OPTIONS[*]}" ${cur}) );
return 0;;
esac
case " ${RPA_LOCAL_PORT_COMMANDS[*]} " in
*" $prev "*)
cmd=list;;
esac
case " ${RPA_REMOTE_PORT_COMMANDS[*]} " in
*" $prev "*)
cmd=query;;
esac
if [ "$cmd" ]; then
COMPREPLY=( $(compgen -W "$(rpa $cmd | ruby -n -e 'puts $1 if /([-\w]+)\s+[0-9]+/')" ${cur} ) )
else
COMPREPLY=( $(compgen -W "${RPA_SIMPLE_COMMANDS[*]} ${RPA_PORT_COMMANDS[*]} ${RPA_OPTIONS[*]}" ${cur} ) )
fi
fi
return 0
}
complete -F _rpa rpa
# 10/11/2004: First release
# 10/12/2004: Patch by Mauricio Ferne$BaOe(Bdez
--
Nobu Nakada