-
Notifications
You must be signed in to change notification settings - Fork 0
Callback
Each patternfile has the form
<digits>-<callback>--<category>
.
The callback identifier with the string '-callback' appended forms the
name of the callback executable. This executable must be located in
${MULLE_MONITOR_DIR}/bin
.
The general expectation is, that a callback is very small and does not take long to execute. A task is something that is longer running and would be running as a background job. In general a callback will only emit a task string and exit.
The executable will be called with the following arguments and environment
Number | Argument | Description |
---|---|---|
$1 | filepath | The file that has changed |
$2 | action | One of three possible strings: "create" "modify" "update" |
$3 | category | The optional category of the matching file |
Remember that
mulle-monitor callback
allows the caller to manually pass any argument he sees fit. mulle-sde uses all empty variables to get a taskname to run its update functionality. The update should be able to incorporate all changes to the filesystem, since the last run of update.
Some environment variables will be available:
Variable | Description |
---|---|
PWD |
This variable and the working directory will be the project folder |
MULLE_MONITOR_DIR |
Location of the .mulle-monitor folder |
MULLE_MONITOR_ETC_DIR |
Location of the etc folder |
MULLE_MONITOR_MATCH_DIR |
Location of the match.d folder |
MULLE_MONITOR_IGNORE_DIR |
Location of the ignore.d folder |
MULLE_MONITOR_LIBEXEC_DIR |
libexec directory of mulle-monitor |
MULLE_BASHFUNCTIONS_LIBEXEC_DIR |
libexec directory of mulle-bashfunctions |
A very simple callback would be:
#! /bin/sh
# could update a Makefile here maybe
# return task
echo "hello"
You can manage callbacks using the mulle-monitor callback
command.
You can pass arguments to the task, by emitting more than just the task name. As the task gets evaled, be sure that your arguments are escaped or quoted properly, so that globbing, expansion and all the other good stuff does not get in the way.
Example:
echo task 'my file with spaces.txt'