Skip to content

Instantly share code, notes, and snippets.

@bendoerr
Created March 19, 2012 20:53
Show Gist options
  • Save bendoerr/2127025 to your computer and use it in GitHub Desktop.
Save bendoerr/2127025 to your computer and use it in GitHub Desktop.
Growl Notifier Script for Grails.
notifications = [
'Final status',
'Status update',
'Status error',
'Plugin installed',
'Created file',
'Created artefact',
'Compile start',
'Compile done',
'Clean done',
'Exiting'
]
imgFile = new File(System.getenv('GRAILS_HOME'), 'media/icons/favicon48.png').toString()
// StatusFinal event is triggered with the last message
// supplied by a script target.
eventStatusFinal = { msg ->
if (msg.startsWith("Server running")) {
growlNotify('Final status', "[$scriptName] Complete", msg, (msg =~ /http.*/)[0])
} else {
growlNotify('Final status', "[$scriptName] Complete", msg)
}
}
// StatusUpdate - every status message that is non-final
eventStatusUpdate = { msg ->
growlNotify('Status update', "[$scriptName] Status", msg)
}
// StatusError - haven't seen this used yet
eventStatusError = { msg->
growlNotify('Status error', "[$scriptName] Error", msg)
}
eventCreatedFile = { fileName ->
growlNotify('Created file', "[$scriptName] Created file", "New file: $fileName")
}
// Exiting - haven't seen this used yet
eventExiting = { code ->
growlNotify('Exiting', "[$scriptName] Exited", "Return code $code")
}
eventCreatedArtefact = { type, file ->
growlNotify('Created artefact', "[${scriptName}] Created artefct", "$type with name $file")
}
eventCompileStart = {
growlNotify('Compile start',
"[${scriptName}] Compiling Source",
"Compiling $grailsAppName $grailsAppVersion ")
}
eventCompileEnd = {
growlNotify('Compile done',
"[${scriptName}] Compilation complete",
"Done compiling $grailsAppName $grailsAppVersion ")
}
eventPluginInstalled = { pluginName ->
growlNotify('Plugin installed', "[${scriptName}] Plugin installed", pluginName)
}
eventCleanEnd = { msg->
growlNotify('Clean done', "[${scriptName}] Done", 'Clean is complete')
}
eventPackagingEnd = {
growlNotify('Packaging End', "[$scriptName] Packaging Complete", '')
}
// Do the business with growlnotify
void growlNotify(category, title, message, callback = null) {
"""growlnotify \
/a:"Grails" \
/r:"${notifications.join('","')}" \
/n:"${category}" \
/t:"${title}" \
/i:"${imgFile}" \
/ai:"${imgFile}" \
${callback ? '/cu:"' + callback + '"' : ""} \
"${message}" \
""".execute()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment