Skip to main content

Crate demogod

Crate demogod 

Source
Expand description

demogod records demos from a tape: a terminal, a browser beside it, or both, typed into and clicked through by a script, and saved as a GIF, an MP4 or WebM, a PNG, or an asciicast.

Output demo.gif
Set Theme "Catppuccin Mocha"

Caption "Run the tests" "in a real shell"
Type "npm test"
Enter
Wait /passing/
Sleep 2s

The tape language is VHS’s, so a VHS tape is a demogod tape; demogod adds captions, a browser pane, and actions run off camera. The terminal is a real PTY rendered by demogod itself — no ttyd, no browser, no ffmpeg — so a terminal demo needs nothing but this crate. And under the default tape timing, every step lasts as long as the tape says it does, not as long as the machine took: the same tape makes the same film, on a laptop or a busy CI runner.

§Recording from Rust

use demogod::Demo;

let saved = Demo::from_file("demo.tape")?
    // `Do break` in the tape runs this, off camera.
    .action("break", || std::fs::write("test/cart-test.ts", "// broken"))
    .run()?;
for file in saved {
    println!("{}: {} bytes", file.path.display(), file.bytes);
}

Demo::record returns the Recording instead, to save wherever and however often. Tape::parse reads a tape without running anything, and Demo::check finds what would fail — a missing program, an undeclared action — before a recording starts.

Structs§

Caption
What the caption strip says during a scene.
Demo
A tape, the actions its Dos may call, and someone to tell how it is going.
Error
What went wrong, and where in the tape if it was the tape’s doing.
Key
A key, and the modifiers held while it is pressed.
Location
A line in a tape: which file, and which line of it, counted from 1.
Pattern
A /regular expression/, compared by how it is written.
Recording
A recorded demo, ready to be saved as a GIF, a video, a PNG or an asciicast.
Rgb
An sRGB color.
Saved
What a saved file came to.
Scene
A caption, and everything that happens while it is on screen.
Settings
Every setting a tape can change with Set.
Step
One line of a tape that does something.
Tape
A parsed tape: its settings, what it writes, and what happens, scene by scene.
Theme
A terminal color scheme.

Enums§

Command
What a step does.
Event
Something worth telling whoever is watching a recording.
Focus
Where a step’s keys go and which screen its Wait reads: Focus terminal or Focus browser.
KeyCode
A key without modifiers.
Length
A width, either in pixels or as a share of the whole.
LoopOffset
Where a GIF starts, as VHS writes it: a frame number, a percentage, or a time.
ScrollTarget
Where Scroll, ScrollUp and ScrollDown go.
Timing
How the recording is timed.
WaitScope
Where in the terminal Wait looks.
WindowBar
The title bar drawn above the terminal.

Type Aliases§

Result
Result with this crate’s Error.