Skip to content

Instantly share code, notes, and snippets.

@breskeby
Created February 8, 2011 18:53
Show Gist options
  • Save breskeby/816972 to your computer and use it in GitHub Desktop.
Save breskeby/816972 to your computer and use it in GitHub Desktop.
#!/bin/bash
tsts="$TM_SELECTED_TEXT"
if [ -z "$TM_SELECTED_TEXT" ]
then
#echo `cat $TM_FILEPATH | grep -Po "(?<=defaultTasks\s\")(.*)(?=\")"`
deftasks=`cat $TM_FILEPATH | grep -Po "(?<=defaultTasks\s\")(.*)(?=\")"`
# if deftask is null open dialog to ask for tasks to execute
if [ -z "$deftasks" ]
then
res=$("$TM_SUPPORT_PATH/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog" inputbox --title "I Need Input" \
--informative-text "Please give me a string:" \
--button1 "Okay" --button2 "Cancel")
echo "dialog done"
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard
res=$(tail -n1 <<<"$res")
tsts="$res"
echo "$tsts"
else
echo "Executing default task(s): $deftasks"
fi
fi
cat << 'EOF1'
<html>
<head>
<script type="text/javascript">
// Declare globally
var outputvar = null;
var accumulator ="";
var tasks = "test";
function launchbuild()
{
var cmd = "/opt/local/share/java/gradle/bin/gradle -b $TM_FILEPATH " + tasks;
outputvar = TextMate.system(cmd, function (fake) {});
// .onreaderror not require as redirecting std err to std out
outputvar.onreadoutput = outputHandler;
}
function outputHandler (currentStringOnStdout)
{
accumulator += currentStringOnStdout;
document.getElementById("results").innerText = accumulator;
}
function donelaunch()
{
document.getElementById("results").innerText = "Stopped";
outputvar.cancel();
}
</script>
</head>
<body onload="launchbuild()">
<pre>
<div id="results">
Starting Gradle build
</div>
</pre>
</body>
</html>
EOF1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment