Dagger
Search

termcast

The termcast module provides a complete API for simulating interactive terminal sessions, and sharing them as GIFs. It can also replay recordings live in the caller's terminal.

Termcast can simulate human keystrokes; execute commands in containers; ask an AI to imagine a scenario; and more.

Installation

dagger install github.com/shykes/daggerverse/termcast@v0.4.1

Entrypoint

Return Type
Termcast !
Arguments
NameTypeDescription
widthInteger Terminal width
heightInteger Terminal height
keySecret OpenAI auth key, for AI features
containerContainer Containerized environment for executing commands
shell[String ! ] Shell to use when executing commands
promptString The prompt shown by the interactive shell
Example
func (m *myModule) example() *Termcast  {
	return dag.
			Termcast()
}
@function
def example() -> dag.Termcast:
	return (
		dag.termcast()
	)
@func()
example(): Termcast {
	return dag
		.termcast()
}

Types

Termcast 🔗

height() 🔗

The height of the terminal

Return Type
Integer !
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 height
func (m *myModule) example(ctx context.Context) int  {
	return dag.
			Termcast().
			Height(ctx)
}
@function
async def example() -> int:
	return await (
		dag.termcast()
		.height()
	)
@func()
async example(): Promise<number> {
	return dag
		.termcast()
		.height()
}

width() 🔗

The width of the terminal

Return Type
Integer !
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 width
func (m *myModule) example(ctx context.Context) int  {
	return dag.
			Termcast().
			Width(ctx)
}
@function
async def example() -> int:
	return await (
		dag.termcast()
		.width()
	)
@func()
async example(): Promise<number> {
	return dag
		.termcast()
		.width()
}

clock() 🔗

Time elapsed since beginning of the session, in milliseconds

Return Type
Integer !
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 clock
func (m *myModule) example(ctx context.Context) int  {
	return dag.
			Termcast().
			Clock(ctx)
}
@function
async def example() -> int:
	return await (
		dag.termcast()
		.clock()
	)
@func()
async example(): Promise<number> {
	return dag
		.termcast()
		.clock()
}

container() 🔗

The containerized environment where commands are executed See Exec()

Return Type
Container !
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 container
func (m *myModule) example() *Container  {
	return dag.
			Termcast().
			Container()
}
@function
def example() -> dagger.Container:
	return (
		dag.termcast()
		.container()
	)
@func()
example(): Container {
	return dag
		.termcast()
		.container()
}

print() 🔗

Simulate data being printed to the terminal, all at once

Return Type
Termcast !
Arguments
NameTypeDefault ValueDescription
dataString !-No description provided
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 print --data string \
 file
func (m *myModule) example(data string) *Termcast  {
	return dag.
			Termcast().
			Print(data)
}
@function
def example(data: str) -> dag.Termcast:
	return (
		dag.termcast()
		.print(data)
	)
@func()
example(data: string): Termcast {
	return dag
		.termcast()
		.print(data)
}

append() 🔗

Append a recording to the end of this recording

Return Type
Termcast !
Arguments
NameTypeDefault ValueDescription
otherTermcast !-No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *myModule) example(other *Termcast) *Termcast  {
	return dag.
			Termcast().
			Append(other)
}
@function
def example(other: dag.Termcast) -> dag.Termcast:
	return (
		dag.termcast()
		.append(other)
	)
@func()
example(other: Termcast): Termcast {
	return dag
		.termcast()
		.append(other)
}

waitRandom() 🔗

Simulate the user waiting for a random amount of time, with no input or output

Return Type
Termcast !
Arguments
NameTypeDefault ValueDescription
minInteger !-The minimum wait time, in milliseconds
maxInteger !-The maximum wait time, in milliseconds
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 wait-random --min integer --max integer \
 file
func (m *myModule) example(min int, max int) *Termcast  {
	return dag.
			Termcast().
			WaitRandom(min, max)
}
@function
def example(min: int, max: int) -> dag.Termcast:
	return (
		dag.termcast()
		.wait_random(min, max)
	)
@func()
example(min: number, max: number): Termcast {
	return dag
		.termcast()
		.waitRandom(min, max)
}

wait() 🔗

Simulate waiting for a certain amount of time, with no input or output on the temrinal

Return Type
Termcast !
Arguments
NameTypeDefault ValueDescription
msInteger !-wait time, in milliseconds
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 wait --ms integer \
 file
func (m *myModule) example(ms int) *Termcast  {
	return dag.
			Termcast().
			Wait(ms)
}
@function
def example(ms: int) -> dag.Termcast:
	return (
		dag.termcast()
		.wait(ms)
	)
@func()
example(ms: number): Termcast {
	return dag
		.termcast()
		.wait(ms)
}

exec() 🔗

Simulate a human running an interactive command in a container

Return Type
Termcast !
Arguments
NameTypeDefault ValueDescription
cmdString !-The command to execute
simpleBoolean falseToggle simple mode. Enabling simple mode is faster and more reliable, but also less realistic: the recording will print the final output all at once, without preserving timing information. Disabling mode is more realistic: the timing of each byte is preserved in the recording; this requires building a binary (which is slow) and injecting it into the target container (which could break).
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 exec --cmd string \
 file
func (m *myModule) example(cmd string) *Termcast  {
	return dag.
			Termcast().
			Exec(cmd)
}
@function
def example(cmd: str) -> dag.Termcast:
	return (
		dag.termcast()
		.exec(cmd)
	)
@func()
example(cmd: string): Termcast {
	return dag
		.termcast()
		.exec(cmd)
}

keystrokes() 🔗

Simulate a human typing text

Return Type
Termcast !
Arguments
NameTypeDefault ValueDescription
dataString !-Data to input as keystrokes
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 keystrokes --data string \
 file
func (m *myModule) example(data string) *Termcast  {
	return dag.
			Termcast().
			Keystrokes(data)
}
@function
def example(data: str) -> dag.Termcast:
	return (
		dag.termcast()
		.keystrokes(data)
	)
@func()
example(data: string): Termcast {
	return dag
		.termcast()
		.keystrokes(data)
}

enter() 🔗

Simulate pressing the enter key

Return Type
Termcast !
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 enter \
 file
func (m *myModule) example() *Termcast  {
	return dag.
			Termcast().
			Enter()
}
@function
def example() -> dag.Termcast:
	return (
		dag.termcast()
		.enter()
	)
@func()
example(): Termcast {
	return dag
		.termcast()
		.enter()
}

backspace() 🔗

Simulate pressing the backspace key

Return Type
Termcast !
Arguments
NameTypeDefault ValueDescription
repeatInteger !1Number of backspaces
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 backspace --repeat integer \
 file
func (m *myModule) example(repeat int) *Termcast  {
	return dag.
			Termcast().
			Backspace(repeat)
}
@function
def example(repeat: int) -> dag.Termcast:
	return (
		dag.termcast()
		.backspace(repeat)
	)
@func()
example(repeat: number): Termcast {
	return dag
		.termcast()
		.backspace(repeat)
}

file() 🔗

Encode the recording to a file in the asciicast v2 format

Return Type
File !
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 file
func (m *myModule) example() *File  {
	return dag.
			Termcast().
			File()
}
@function
def example() -> dagger.File:
	return (
		dag.termcast()
		.file()
	)
@func()
example(): File {
	return dag
		.termcast()
		.file()
}

encode() 🔗

Encode the recording to a string in the asciicast v2 format

Return Type
String !
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 encode
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			Termcast().
			Encode(ctx)
}
@function
async def example() -> str:
	return await (
		dag.termcast()
		.encode()
	)
@func()
async example(): Promise<string> {
	return dag
		.termcast()
		.encode()
}

play() 🔗

Return an interactive terminal that will play the recording, read-only.

Return Type
Terminal !
Example
Function Termcast.play is not accessible from the termcast module
func (m *myModule) example() *Terminal  {
	return dag.
			Termcast().
			Play()
}
@function
def example() -> dag.Terminal:
	return (
		dag.termcast()
		.play()
	)
@func()
example(): Terminal {
	return dag
		.termcast()
		.play()
}

gif() 🔗

Encode the recording into an animated GIF files

Return Type
File !
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 gif
func (m *myModule) example() *File  {
	return dag.
			Termcast().
			Gif()
}
@function
def example() -> dagger.File:
	return (
		dag.termcast()
		.gif()
	)
@func()
example(): File {
	return dag
		.termcast()
		.gif()
}

decode() 🔗

Decode an asciicast v2 file, and add its contents to the end of the recording. See https://docs.asciinema.org/manual/asciicast/v2/

Return Type
Termcast !
Arguments
NameTypeDefault ValueDescription
dataString !-The data to decode, in asciicast format
expectHeaderBoolean !trueIndicate whether the decoder should expect an asciicast header. If true, the decoder will parse (and discrd) the header, the load the events If false, the decoder will look for events directly
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 decode --data string --expect-header boolean \
 file
func (m *myModule) example(data string, expectHeader bool) *Termcast  {
	return dag.
			Termcast().
			Decode(data, expectHeader)
}
@function
def example(data: str, expect_header: bool) -> dag.Termcast:
	return (
		dag.termcast()
		.decode(data, expect_header)
	)
@func()
example(data: string, expectHeader: boolean): Termcast {
	return dag
		.termcast()
		.decode(data, expectHeader)
}

imagine() 🔗

Ask an AI to imagine a terminal session, and add it to the recording

Return Type
Termcast !
Arguments
NameTypeDefault ValueDescription
promptString !"surprise me! an epic interactive session with a shell, language repl or database repl of your choice. the more exotic the better. Not python!"A description of the terminal session
Example
dagger -m github.com/shykes/daggerverse/termcast@921afbccaf2f57ea42461353124e66c7d43112fe call \
 imagine --prompt string \
 file
func (m *myModule) example(prompt string) *Termcast  {
	return dag.
			Termcast().
			Imagine(prompt)
}
@function
def example(prompt: str) -> dag.Termcast:
	return (
		dag.termcast()
		.imagine(prompt)
	)
@func()
example(prompt: string): Termcast {
	return dag
		.termcast()
		.imagine(prompt)
}