XTomate
Your poweful automation ally
Introduction
XTomate is a simple automation tool that allows you to define workflows in TOML files and run them. It is designed to be simple to use and easy to extend.
Installation
The easiest way to install XTomate is to clone the repository and install with cargo.
Usage
To run a workflow, you need to create a TOML file with the workflow definition and run the xt
command with the path to the file.
Plugins
XTomate is designed to be extensible with plugins. Plugins are simple dynamic libraries that implement necessary traits.
Each plugin needs to implement a initialize
function, a execute
function and a teardown
function. The initialize
function is called when the plugin is loaded, the execute
function is called when the plugin is used and the teardown
function is called when the plugin is unloaded.
Both the initialize
and execute
functions take a JSON object encoded as a string as an argument. This object contains the configuration for the plugin. The teardown
function does not take any arguments.
All functions return a 32-bit integer. A return value of 0 indicates success, while a non-zero value indicates an error.
Any plugin that will be loaded should be placed in the plugins
directory in the root of the project. The user may also specify a custom directory to load plugins from using the --plugins
flag.
Writing a plugin
(I will write a more detailed guide later, but for now just extend this template)
// Libraries used by the plugin
use CStr;
use c_char;
use ;
use ;
use serde_json;
// Configuration struct for the plugin
// Input struct for the plugin
// Global variable to store the app name
static APP_NAME: = new;
// Plugin initialization function
pub extern "C"
// Plugin execution function
pub extern "C"
// Plugin teardown function
pub extern "C"
Workflow TOML syntax
(Partially so that I don't forget)
# Basic workflow information
= "example"
= "0.1.0" # XTomate version required to run the workflow
# Tasks to run on special events
= ["log_start"]
= ["notify_send", "log_done"]
# Plugin configurations
[[]]
= "notify_send" # Plugin name
= "https://github.com/vyPal/xtomate-plugin-notify-send" # Plugin source
= "^0.1.0" # Plugin version
= { = "XTomate" } # Plugin configuration
[[]]
= "logger"
= "vyPal/xtomate-plugin-logger" # Shorter way to write source
= "^0.1.0"
= { = "XTomate", = "xtomate.log" }
# Task configurations
[]
= false # This will prevent the task to run on its own, it will have to be called explicitly
= "notify_send" # Plugin to use
= { = "Workflow finished" } # Plugin configuration
[]
= false
= "logger"
= { = "Workflow finished", = "info", = "Status" }
[]
= false
= "logger"
= { = "Workflow started", = "info", = "Status" }
[]
# Command to run
= """
mkdir testdir
cd testdir
touch hello.py
"""
[]
= '''
echo "print('hello world')" > testdir/hello.py
'''
= [{ = "success"}] # Dependencies to run before this task
[]
= '''
echo "$WORLD $HELLO" > testdir/hello.txt
'''
= [{ = "success"}] # Dependencies to run before this task with a specific status
= { = "world", = "hello"} # Environment variables to set before running the command
[]
= "python testdir/hello.py && cat testdir/hello.txt"
= [{ = "success"}, { = "success"}]