41 lines
803 B
Go
41 lines
803 B
Go
|
package cast
|
||
|
|
||
|
import (
|
||
|
"forge.cadoles.com/arcad/edge/pkg/module/cast"
|
||
|
"github.com/pkg/errors"
|
||
|
"github.com/urfave/cli/v2"
|
||
|
)
|
||
|
|
||
|
func LoadURLCommand() *cli.Command {
|
||
|
return &cli.Command{
|
||
|
Name: "load-url",
|
||
|
Usage: "Load `URL` in casting device",
|
||
|
Flags: []cli.Flag{
|
||
|
&cli.StringFlag{
|
||
|
Name: "device",
|
||
|
Aliases: []string{"d"},
|
||
|
Required: true,
|
||
|
},
|
||
|
&cli.StringFlag{
|
||
|
Name: "url",
|
||
|
Aliases: []string{"u"},
|
||
|
Required: true,
|
||
|
},
|
||
|
},
|
||
|
Action: func(ctx *cli.Context) error {
|
||
|
device := ctx.String("device")
|
||
|
url := ctx.String("url")
|
||
|
|
||
|
if err := cast.StopCast(ctx.Context, device); err != nil {
|
||
|
return errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
if err := cast.LoadURL(ctx.Context, device, url); err != nil {
|
||
|
return errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
},
|
||
|
}
|
||
|
}
|