Crate castwright

Source
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 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();
    let castwright = CastWright::new();
    castwright.run(&mut reader, &mut stdout)?;
    Ok(())
}

See src/main.rs for a complete example.

Structs§

AsciiCast
An asciicast v2 file.
CastWright
The CastWright struct represents the main entry point for the CastWright library. An instance of CastWright can be configured, parses and executes CastWright scripts, and writes the resulting asciicast to a writer.
Error
The Error struct represents an error that occurred during parsing or execution, with the line number denoting its position. To construct an Error manually, you should call with_line on an ErrorType enum variant. Usually, you’ll only need this struct in a function signature to propagate errors.

Enums§

ErrorType
Possible types of errors that can occur while parsing a single line of a .cwrt file. An enum variant represents a specific type of error, and can be converted to an Error with the with_line method. (See the Error struct for an example)