Repository navigation
Releases: chromedp/termcast
Releases · chromedp/termcast
Release list
v0.2.2
v0.2.1
v0.2.0
New option WithElement draws only the element that a chromedp selector finds, and not the whole page. The stream looks the element up again at each frame, so an element that moves or changes its size stays in view. The README also lists the example programs that use termcast.
v0.1.1
v0.1.0
This is the first release of termcast. The package streams the screen of a chromedp page to a terminal that has graphics, with the screencast of the Chrome DevTools Protocol and the package rasterm. It works in Kitty, iTerm2 and Sixel terminals.
var tc termcast.Flags
tc.Register(flag.CommandLine)
flag.Parse()
// ... create the chromedp context ...
s, err := tc.Start(ctx, *verbose)
if err != nil {
log.Fatal(err)
}
defer s.Stop()
log.SetOutput(s.LogWriter())What it does
Startdraws the page at 4 frames per second by default. AWithFPSoption or the flag-terminal-fpschanges the rate.- Each redraw clears the terminal and draws the latest frame. The package uses no alternate screen and does not hide the cursor, so a program that ends with
log.Fatalnever leaves the terminal in a changed state. - The browser sends a frame only when the page changes. The stream keeps the latest frame, so a page that stops changing stays on the screen.
StartreturnsErrNoGraphicswhen the terminal has no graphics. The message names the terminals that work and the variableTERM_GRAPHICSthat forces a type.Stream.LogWriterholds the log lines of the program while the stream runs, and prints them after a final frame when the stream stops. Every method of*Streamis safe on a nil pointer, so a program can calls.Stop()ands.Fatal(err)whether the stream is on or off.Flagsregisters-visible-on-terminaland-terminal-fps, andFlags.StartreturnsErrVerbosewhen the stream is on together with-v, because the protocol messages would draw over the frames.- The options
WithQuality,WithMaxSize,WithOutput,WithLogOutputandWithEncoderchange the JPEG quality, the frame size, the writers and the encoder.
Install
go get github.com/chromedp/termcast@v0.1.0The package needs Go 1.27 or later and chromedp v0.19.0.