175 lines
3.4 KiB
Bash
Executable File
175 lines
3.4 KiB
Bash
Executable File
#!/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+=("$javaclass" "$codeline")
|
|
done
|
|
javaclass=$($DIALOG --menu "Edit 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
|
|
}
|
|
|
|
}
|
|
|
|
edit_properties()
|
|
{
|
|
local property_file=$1
|
|
if [[ -f $property_file ]]
|
|
then
|
|
modified=0
|
|
s=()
|
|
properties=()
|
|
values=()
|
|
{
|
|
while read codeline
|
|
do
|
|
if [[ $codeline =~ (^[a-zA-Z_]*)=(.*) ]]
|
|
then
|
|
property=${BASH_REMATCH[1]}
|
|
value=${BASH_REMATCH[2]}
|
|
s+=("$property" "$value")
|
|
properties+=("$property")
|
|
values+=("$value")
|
|
fi
|
|
done
|
|
s+=(exit "Exit")
|
|
} < $property_file
|
|
|
|
while true
|
|
do
|
|
property=$($DIALOG --menu "Edit '$property_file'" 20 100 10 ${s[@]} 3>&1 1>&2 2>&3)
|
|
if [[ $? = 0 ]]
|
|
then
|
|
if [[ -n $property ]]
|
|
then
|
|
if [[ $property == exit ]]
|
|
then
|
|
return 1
|
|
elif [[ $property == save ]]
|
|
then
|
|
for (( i=0; i<${prop_len}; i++ ));
|
|
do
|
|
echo "${properties[$i]}=${values[$i]}"
|
|
done >$property_file
|
|
return 0
|
|
fi
|
|
prop_len="${#properties[@]}"
|
|
for (( i=0; i<${prop_len}; i++ ));
|
|
do
|
|
if [[ ${properties[$i]} == $property ]]
|
|
then
|
|
init_value=${values[$i]}
|
|
fi
|
|
done
|
|
value=$($DIALOG --inputbox "Enter $property value" 10 80 "$init_value" 3>&1 1>&2 2>&3)
|
|
if [[ $? = 0 ]]
|
|
then
|
|
prop_len="${#properties[@]}"
|
|
s=()
|
|
if [[ "$value" != "$init_value" ]]
|
|
then
|
|
modified=$(( modified + 1 ))
|
|
fi
|
|
for (( i=0; i<${prop_len}; i++ ));
|
|
do
|
|
if [[ ${properties[$i]} == $property ]]
|
|
then
|
|
values[$i]=$value
|
|
fi
|
|
s+=("${properties[$i]}" "${values[$i]}")
|
|
echo "${properties[$i]}=${values[$i]}"
|
|
done
|
|
s+=(exit "Exit")
|
|
if [[ $modified != 0 ]]
|
|
then
|
|
s+=(save "Save")
|
|
fi
|
|
fi
|
|
fi
|
|
else
|
|
return 2
|
|
fi
|
|
done
|
|
else
|
|
echo "[ERROR] property_file '$propertyfile' not found" >&2
|
|
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 "Ultra Light IDE" 20 80 12 run "Run it" clean "Clean All" ant "Ant build" test "Test it" readme "Read me" code "Code" codebg "Code in background" deb "Debian package" properties "Edit Properties" quit "Quit" 3>&1 1>&2 2>&3)
|
|
|
|
if [[ $action == run ]]
|
|
then
|
|
echo "run it"
|
|
java -jar $(make getname)
|
|
elif [[ $action == ant ]]
|
|
then
|
|
make clean
|
|
make
|
|
ant compile
|
|
elif [[ $action == clean ]]
|
|
then
|
|
make clean
|
|
pushd java
|
|
make clean
|
|
popd
|
|
elif [[ $action == test ]]
|
|
then
|
|
echo "test it"
|
|
pushd java
|
|
make display
|
|
popd
|
|
elif [[ $action == deb ]]
|
|
then
|
|
make deb
|
|
elif [[ $action =~ code ]]
|
|
then
|
|
do_code $action
|
|
elif [[ $action == readme ]]
|
|
then
|
|
$DIALOG --textbox README 20 80
|
|
elif [[ $action == properties ]]
|
|
then
|
|
edit_properties project_params
|
|
fi
|
|
done
|