isCanceled
Checks if the user has pressed cancel in the app. A recipe should check this value within long multistep processes
Syntax
isCanceled()
Returns
returns (integer) true if the user has pressed cancel.
Parameters
None
Usage
Example usage
You can use isCanceled
in the cmd_callback
when using log commands.
// Main function that executes a command to invoke the terminal app 'sleep'.
// This command causes the program to pause for 10 minutes before continuing.
function main() {
// Calls the 'sleep' command with an argument of '10m' (10 minutes).
cmd( "sleep", [ '10m', ]);
}
// Callback function that is invoked regularly during the execution of the 'sleep' command
// This function checks if the command should be terminated based on a user cancellation action.
function cmd_callback(cmd_name, cmd_output){
// Checks if the command has been canceled and returns an object with instructions for the command.
return {
// Stop the command if the user has indicated it should be canceled.
"terminate": isCanceled(),
// No additional input is sent to the command.
"input": ""
};
}