gut-plugin
Helper library that provides a macro to create plugins for gut.
The gut plugin system loads plugins that are written in wasm
that are located in the gut directory $HOME/.gut
.
How to create a gut plugin
- Create a new library using cargo
- Add the following to the
Cargo.toml
:
[]
= "gut_myplugin"
= ["cdylib"]
[]
= "0.1.0"
- Use the provided macro to export the function
use slice;
use str;
// gut_export!([names], [descriptions])
// names: [&str] - the names of the functions to export.
// descriptions: [&str] - the descriptions of the functions to export.
gut_export!;
// all exported functions must have this signature:
//
// #[no_mangle]
// fn_name(ptr: i32, len: i32)
//
// this is becuase gut will invoke the function and pass a string if one is provided.
// example:
// $ gut my_plugin "world"
- Build
# you may need to add wasm32-wasi target to build wasm
# build
# move to gut directory