termcast
This module uses Asciinema to: - Compose terminal recordings in code - Replay recordings directly in the terminal, or generate a gif - Simulate human keystrokes and terminal output - Execute any commands in any container, and make it look like a human did it interactively - Ask an AI to imagine a terminal session, and add it to the recordingInstallation
dagger install github.com/shykes/daggerverse/termcast@v0.4.0
Entrypoint
Return Type
Termcast !
Arguments
Name | Type | Description |
---|---|---|
width | Integer | Terminal width |
height | Integer | Terminal height |
key | Secret | OpenAI auth key, for AI features |
container | Container | Containerized environment for executing commands |
shell | [String ! ] | Shell to use when executing commands |
prompt | String | The prompt shown by the interactive shell |
Example
dagger -m github.com/shykes/daggerverse/termcast@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc 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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc 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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc 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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc 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
Name | Type | Default Value | Description |
---|---|---|---|
data | String ! | - | No description provided |
Example
dagger -m github.com/shykes/daggerverse/termcast@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
print --data string
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
Name | Type | Default Value | Description |
---|---|---|---|
other | Termcast ! | - | 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
Name | Type | Default Value | Description |
---|---|---|---|
min | Integer ! | - | The minimum wait time, in milliseconds |
max | Integer ! | - | The maximum wait time, in milliseconds |
Example
dagger -m github.com/shykes/daggerverse/termcast@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
wait-random --min integer --max integer
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
Name | Type | Default Value | Description |
---|---|---|---|
ms | Integer ! | - | wait time, in milliseconds |
Example
dagger -m github.com/shykes/daggerverse/termcast@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
wait --ms integer
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
Name | Type | Default Value | Description |
---|---|---|---|
cmd | String ! | - | The command to execute |
simple | Boolean | false | Toggle 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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
exec --cmd string
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
Name | Type | Default Value | Description |
---|---|---|---|
data | String ! | - | Data to input as keystrokes |
Example
dagger -m github.com/shykes/daggerverse/termcast@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
keystrokes --data string
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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
enter
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
Name | Type | Default Value | Description |
---|---|---|---|
repeat | Integer ! | 1 | Number of backspaces |
Example
dagger -m github.com/shykes/daggerverse/termcast@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
backspace --repeat integer
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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc 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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc 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
dagger -m github.com/shykes/daggerverse/termcast@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
play
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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc 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
Name | Type | Default Value | Description |
---|---|---|---|
data | String ! | - | The data to decode, in asciicast format |
expectHeader | Boolean ! | true | Indicate 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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
decode --data string --expect-header boolean
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
Name | Type | Default Value | Description |
---|---|---|---|
prompt | String ! | "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@4f1667dcc120c6a6fddc956cc0d1f79ab97881bc call \
imagine --prompt string
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)
}