Skip to content

Commit

Permalink
breakroom auto mode re-run on any zencode modification
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromil committed Nov 12, 2023
1 parent c12218d commit f4b77f3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/breakroom/breakroom
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ keys=0
data=0
extra=0
break=0
onfail="trace"
EOF
}
if ! [ -r $bconf ]; then
Expand Down Expand Up @@ -93,6 +94,7 @@ if [ "$1" = "-h" ]; then
_message " trace 🧭 show the backtrace of current execution"
_message " heap 💾 show the HEAP of current execution"
_message " codec 🗃️ show the CODEC of Given scope execution"
_message " auto ♻️ onitor zencode and re-run on modifications"
_message " script [file] ⚡ get/set the zencode script file"
_message " data [file] 🔡 get/set the data JSON input file"
_message " keys [file] 🔢 get/set the keys JSON input file"
Expand Down Expand Up @@ -159,13 +161,20 @@ _execute() {
if [ $? = 0 ]; then
cat breakroom.exec.stdout | jq .
_success "Execution succesful"
return 0
else
cat breakroom.exec.stderr | grep -v "^\"J64"
_error "Failed execution"
_getJ64 "TRACE"
return 1
fi
}

if [ "$1" = "run" ]; then
_execute
exit $?
fi

tcmd=`mktemp`
while true; do
# read command from prompt
Expand Down Expand Up @@ -216,6 +225,23 @@ while true; do
codec|schema|given)
_execute "scope=given"
;;
auto)
if ! command -v inotifywait; then
_error "Cannot find inotify-tools for auto mode"
continue
fi
tscript="$script"; [ $tscript = 0 ] && tscript=""
tdata="$data"; [ $tdata = 0 ] && tdata=""
tkeys="$keys"; [ $tkeys = 0 ] && tkeys=""
textra="$extra"; [ $textra = 0 ] && textra=""
while true; do
_success "AUTO mode: autorun on zencode changes"
inotifywait -q \
-e modify \
"${tscript}" "${tdata}" "${tkeys}" "${textra}"
_execute
done
;;
esac
else
# SET
Expand Down
2 changes: 2 additions & 0 deletions src/breakroom/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ int main(int argc, char **argv) {
CMD("trace"); CMD("bt");
CMD("heap");
CMD("codec"); CMD("schema"); CMD("given");
CMD("auto");
CMD("onfail");
fprintf(stdout,"Unknown command: %s\n", line);
free(line);
}
Expand Down

0 comments on commit f4b77f3

Please sign in to comment.