Documentation
¶
Overview ¶
Package cast contains the essential structures for dealing with an asciinema cast of the v2 format.
The current implementation is based on the V2 format as of July 2nd, 2018.
From 1, asciicast v2 file is a newline-delimited JSON file where:
- first line contains header (initial terminal size, timestamp and other meta-data), encoded as JSON object; and
- all following lines form an event stream, each line representing a separate event, encoded as 3-element JSON array.
Index ¶
- func Encode(writer io.Writer, cast *Cast) (err error)
- func Validate(cast *Cast) (isValid bool, err error)
- func ValidateEvent(event *Event) (isValid bool, err error)
- func ValidateEventStream(eventStream []*Event) (isValid bool, err error)
- func ValidateHeader(header *Header) (isValid bool, err error)
- type Cast
- type Event
- type Header
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
Encode writes the encoding of `Cast` into the writer passed as an argument.
ps.: this method **will not** validate whether the cast is a valid V2 cast or not. Make sure you call `Validate` before.
func ValidateEvent ¶
ValidateEvent checks whether the provided `Event` is properly formed.
func ValidateEventStream ¶
ValidateEventStream makes sure that a given set of events (event stream) is valid.
A valid stream must: - be ordered by time; and - have valid events.
func ValidateHeader ¶
ValidateHeader verifies whether the provided `cast` header structure is valid or not based on the asciinema cast v2 protocol.
Types ¶
type Cast ¶
type Cast struct { // Header presents the recording metadata. Header Header // EventStream contains all the events that were generated during // the recording. EventStream []*Event }
Cast represents the whole asciinema session.
type Event ¶
type Event struct { // Time indicates when this event happened, represented as the number // of seconds since the beginning of the recording session. Time float64 // Type represents the type of the data that's been recorded. // // Two types are possible: // - "o": data written to stdout; and // - "i": data read from stdin. Type string // Data represents the data recorded from the terminal. Data string }
Event represents terminal inputs that get recorded by asciinema.
type Header ¶
type Header struct { // Version represents the version of the current ascii cast format // (must be `2`). // // This field is required for a valid header. Version uint8 `json:"version"` // With is the initial terminal width (number of columns). // // This field is required for a valid header. Width uint `json:"width"` // Height is the initial terminal height (number of rows). // // This field is required for a valid header. Height uint `json:"height"` // Timestamp is the unix timestamp of the beginning of the // recording session. Timestamp uint `json:"timestamp,omitempty"` // Command corresponds to the name of the command that was // recorded. Command []string `json:"command,omitempty"` // Theme describes the color theme of the recorded terminal. Theme struct { // Fg corresponds to the normal text color (foreground). Fg string `json:"fg,omitempty"` // Bg corresponds to the normal background color. Bg string `json:"bg,omitempty"` // Palette specifies a list of 8 or 16 colors separated by // colon character to apply a theme to the session Palette string `json:"palette,omitempty"` } `json:"theme,omitempty"` // Title corresponds to the title of the cast. Title string `json:"title,omitempty"` // IdleTimeLimit specifies the maximum amount of idleness between // one command and another. IdleTimeLimit float64 `json:"idle_time_limit,omitempty"` // Env specifies a map of environment variables captured by the // asciinema command. // // ps.: the official asciinema client only captures `SHELL` and `TERM`. Env map[string]string `json:"env,omitempty"` }
Header represents the asciicast header - a JSON-encoded object containing recording meta-data.