2015-02-24 16:22:31 +01:00
|
|
|
package commands
|
|
|
|
|
|
2016-02-21 16:58:39 +01:00
|
|
|
import (
|
|
|
|
|
"github.com/asciinema/asciinema/asciicast"
|
|
|
|
|
"github.com/asciinema/asciinema/util"
|
|
|
|
|
)
|
2015-02-24 16:22:31 +01:00
|
|
|
|
|
|
|
|
type PlayCommand struct {
|
|
|
|
|
Player asciicast.Player
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-03 16:13:33 +01:00
|
|
|
func NewPlayCommand() *PlayCommand {
|
2015-02-24 16:22:31 +01:00
|
|
|
return &PlayCommand{
|
|
|
|
|
Player: asciicast.NewPlayer(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 20:18:00 +02:00
|
|
|
func (c *PlayCommand) Execute(url string, maxWait float64) error {
|
2016-02-21 16:58:39 +01:00
|
|
|
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)
|
2015-02-24 16:22:31 +01:00
|
|
|
}
|