mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 11:48:13 +01:00
32 lines
523 B
Go
32 lines
523 B
Go
package commands
|
|
|
|
import (
|
|
"github.com/asciinema/asciinema/asciicast"
|
|
"github.com/asciinema/asciinema/util"
|
|
)
|
|
|
|
type PlayCommand struct {
|
|
Player asciicast.Player
|
|
}
|
|
|
|
func NewPlayCommand() *PlayCommand {
|
|
return &PlayCommand{
|
|
Player: asciicast.NewPlayer(),
|
|
}
|
|
}
|
|
|
|
func (c *PlayCommand) Execute(url string, maxWait float64) error {
|
|
var cast *asciicast.Asciicast
|
|
var err error
|
|
|
|
util.WithSpinner(500, func() {
|
|
cast, err = asciicast.Load(url)
|
|
})
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.Player.Play(cast, maxWait)
|
|
}
|