The Kaptain on … stuff

03 Apr, 2009

Griffon bash completion…

Posted by: TheKaptain In: Development

… means I don’t have to remember all of the available Griffon commands. My primary development platform is a Mac, so I used MacPorts to install the bash-completion package long ago.
This script is based entirely on the excellent maven completion script documented here on willcodeforbeer. It does the same job for Griffon and includes commands for the plugins I’m using.
[bash smarttabs=”true” language=”language=”]
# Griffon completion for the bash shell
#
_griffon()
{
local cmds cur colonprefixes
cmds="bootstrap clean compile console create-app \
create-fest-test create-integration-test create-mvc \
create-plugin create-script create-unit-test \
create-fest-test run-fest -cobertura help init \
install-plugin list-plugins package package-plugin \
plugin-info release-plugin run-app run-applet run-fest \
run-webstart set-proxy set-version shell stats test-app \
test-app-cobertura uninstall-plugin upgrade"
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
# Work-around bash_completion issue where bash interprets a colon
# as a separator.
# Work-around borrowed from the darcs work-around for the same
# issue.
colonprefixes=${cur%"${cur##*:}"}
COMPREPLY=( $(compgen -W ‘$cmds’ — $cur))
local i=${#COMPREPLY[*]}
while [ $((–i)) -ge 0 ]; do
COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
done

return 0
} &&
complete -F _griffon griffon
[/bash]

Add this to your .bash_profile file and you’re good to go for saving a whole bunch of keystrokes and calls to ‘griffon help’.

Reblog this post [with Zemanta]

2 Responses to "Griffon bash completion…"

1 | Andres Almiray

April 4th, 2009 at 8:27 am

Avatar

Here is another bash completion script (based on Grails) that will also take into account plugin scripts

http://svn.codehaus.org/griffon/core/trunk/bash/griffon-auto-scripts

2 | TheKaptain

April 4th, 2009 at 8:48 am

Avatar

Thanks for pointing me to it Andres! That certainly beats the heck out of my brute force attempt. Will be incorporating it immediately. Great work on the book so far by the way. Looking forward to the next chapter!

Comment Form