Expand description
§CastWright
🎥 Scripted terminal recording.
§Note
- This project is still in the early stages of development, with some core features missing or incomplete.
- If you see this message, it means that you’re viewing the documentation of the
castwrightlibrary. For the CLI, please refer to the README; for the CastWright script format, please refer to the REFERENCE.
§Usage
Mostly, you’ll deal with the CastWright struct and Error struct. When you want to you manually create errors, you need to deal with the ErrorType enum. If you’re writing your own tool for generating asciicasts, you can use the AsciiCast struct.
§Example
use castwright::{CastWright, Error};
use std::io::BufReader;
fn main() -> Result<(), Error> {
let text = r#"
$ echo "Hello, World!"
$ echo "Multi-" \
> "line" \
> "command"
"#;
let text = text.trim();
let mut reader = BufReader::new(text.as_bytes());
let mut stdout = std::io::stdout().lock();
let castwright = CastWright::new();
castwright.run(&mut reader, &mut stdout)?;
Ok(())
}See src/main.rs for a complete example.
Structs§
- Ascii
Cast - An asciicast v2 file.
- Cast
Wright - The
CastWrightstruct represents the main entry point for the CastWright library. An instance ofCastWrightcan be configured, parses and executes CastWright scripts, and writes the resulting asciicast to a writer. - Error
- The
Errorstruct represents an error that occurred during parsing or execution, with the line number denoting its position. To construct anErrormanually, you should callwith_lineon anErrorTypeenum variant. Usually, you’ll only need this struct in a function signature to propagate errors.