43 lines
832 B
Go
43 lines
832 B
Go
package cast
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"forge.cadoles.com/arcad/edge/pkg/module/cast"
|
|
"github.com/pkg/errors"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func StopCastCommand() *cli.Command {
|
|
return &cli.Command{
|
|
Name: "stop-cast",
|
|
Usage: "Stop casting process on device",
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "device",
|
|
Aliases: []string{"d"},
|
|
Required: true,
|
|
},
|
|
&cli.DurationFlag{
|
|
Name: "timeout",
|
|
Aliases: []string{"t"},
|
|
Value: 10 * time.Second,
|
|
},
|
|
},
|
|
Action: func(ctx *cli.Context) error {
|
|
device := ctx.String("device")
|
|
timeout := ctx.Duration("timeout")
|
|
|
|
timeoutCtx, cancel := context.WithTimeout(ctx.Context, timeout)
|
|
defer cancel()
|
|
|
|
if err := cast.StopCast(timeoutCtx, device); err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
return nil
|
|
},
|
|
}
|
|
}
|