Components
With components your script can access core functionality of the Cereal application. The onStart, execute and
onFinish method in your Scripts' implementation contain a ComponentProvider which gives access to these components.
Available Components
Each component provides specific functionality to your script:
- Logger — Log output to the Cereal application
- Notification — Send desktop notifications and messages to external services
- Preference — Store and retrieve persistent data
- User Interaction — Ask the user for input during execution
- Script Launcher — Start child scripts from your main script
A license() accessor is also available on ComponentProvider. It's a transport adapter used by the LicenseChecker from the Cereal License Verification library — see Adding Verification for usage.
Accessing Components
Every component can be accessed through the ComponentProvider that's passed to your script's methods:
suspend fun execute(provider: ComponentProvider) {
val logger = provider.logger()
val notification = provider.notification()
val preference = provider.preference()
val userInteraction = provider.userInteraction()
val scriptLauncher = provider.scriptLauncher()
logger.info("Script started")
preference.setString("lastRun", LocalDateTime.now().toString())
}
Refer to each component's dedicated documentation page for detailed usage instructions and examples.