Expand description
🎥 Scripted terminal recording.
§Note
If you see this message, it means that you’re viewing the documentation of the castwright library. 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(); // Consider wrapping in a BufWriter for better performance
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 instance, streaming content to a writer.
- Cast
Wright - The
CastWrightstruct represents the main entry point for theCastWrightlibrary. - Error
- The
Errorstruct represents an error that occurred during parsing or execution, with the line number denoting its position.
Enums§
- Error
Type - Possible types of errors that can occur while parsing or executing a single line of a
CastWrightscript. Each variant represents a specific type of error, and can be converted to anErrorwith thewith_linemethod. (See theErrorstruct for examples)
Constants§
- VERSION
- The version of the
CastWrightlibrary.