Crate castwright

Crate castwright 

Source
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§

AsciiCast
An asciicast v2 instance, streaming content to a writer.
CastWright
The CastWright struct represents the main entry point for the CastWright library.
Error
The Error struct represents an error that occurred during parsing or execution, with the line number denoting its position.

Enums§

ErrorType
Possible types of errors that can occur while parsing or executing a single line of a CastWright script. Each variant represents a specific type of error, and can be converted to an Error with the with_line method. (See the Error struct for examples)

Constants§

VERSION
The version of the CastWright library.