Command Logic
The command logic is how command that gets execute is generated using the form
data. The command logic is written in javascript and the form data is passed
as an object in variable form
. What ever string you return will be the command
that is executed inside the respository directory on the specified machine.
You are able to throw errors during this process and the Signal will not be executed on machine and be labeled as fail. Asynchronous process are not allowed.
Example
Command Logic
if (form.gender != "Male" && form.gender != "Female") throw new Error("Gender is missing");
let age = new Date().getFullYear() - form.birth_year;
if (age < 18) {
return `py ./scripts/add-child.py ${form.name} --sex ${(form.gender == "Male") ? "M" : "F"} --email "${form.email}"`
} else {
return `py ./scripts/add-adult.py ${form.name} --sex ${(form.gender == "Male") ? "M" : "F"} --email "${form.email}"`
}
Form Example 1
{
"name": "Reilly",
"birth_year": "1999"
}
Will result in an error being thrown because gender
is missing. Note:
it would be better to set gender
as a required attribute in the
form schema, this is just an illistration.
Form Example 2
{
"name": "Reilly",
"birth_year": "1999",
"gender": "Female"
}
py ./scripts/add-adult.py Reilly --sex F --email "undefined"
Form Example 3
{
"name": "Reilly",
"birth_year": "2010",
"gender": "Female",
"email": "[email protected]"
}
py ./scripts/add-child.py Reilly --sex F --email "[email protected]"