add a shell script to code & run

Signed-off-by: philippe lhardy <philippe@pavilionartlogiciel>
This commit is contained in:
philippe lhardy
2015-02-09 20:48:08 +01:00
parent a041e3d82c
commit bd4a6dfc29
3 changed files with 86 additions and 9 deletions

75
doit.sh Executable file
View File

@@ -0,0 +1,75 @@
#!/bin/bash
do_code()
{
background=$1
find java/org/artisanlogiciel/games/ -name "*.java" |
{
s=
while read codeline
do
javafile=$(basename $codeline)
javaclass=${javafile/.java/}
echo "$javafile $javaclass"
s="$s $javaclass $codeline"
done
javaclass=$($DIALOG --menu "Run it" 20 100 10 $s 3>&1 1>&2 2>&3)
if [[ -n $javaclass ]]
then
pushd java
if [[ $background == codebg ]]
then
nohup make work/$javaclass &
else
make work/$javaclass
fi
popd
fi
}
}
possible_console_gui="whiptail dialog"
for DIALOG in $possible_console_gui
do
DIALOG=$(which $DIALOG)
if [[ -n $DIALOG ]]
then
break
fi
done
if [[ -z $DIALOG ]]
then
echo "no console gui support (within $possible_console_gui) => no menus "
exit 1
fi
action=initial
while [[ $action != quit ]]
do
action=$($DIALOG --menu "Run it" 20 80 8 run "Run it" test "Test it" readme "Read me" code "Code" codebg "Code in background" quit "Quit" 3>&1 1>&2 2>&3)
if [[ $action == run ]]
then
echo "run it"
pushd java
make display
popd
elif [[ $action == test ]]
then
echo "test it"
pushd java
make display
popd
elif [[ $action =~ code ]]
then
do_code $action
elif [[ $action == readme ]]
then
$DIALOG --textbox README 20 80
fi
done