package cast import ( "context" "log" "time" "forge.cadoles.com/arcad/edge/pkg/module/cast" "github.com/pkg/errors" "github.com/urfave/cli/v2" ) func ScanCommand() *cli.Command { return &cli.Command{ Name: "scan", Usage: "Scan network for casting devices", Flags: []cli.Flag{ &cli.DurationFlag{ Name: "timeout", Aliases: []string{"t"}, Value: 30 * time.Second, }, }, Action: func(ctx *cli.Context) error { timeout := ctx.Duration("timeout") searchCtx, cancel := context.WithTimeout(ctx.Context, timeout) defer cancel() devices, err := cast.SearchDevices(searchCtx) if err != nil { log.Fatalf("%+v", errors.WithStack(err)) } for dev := range devices { log.Printf("[DEVICE] %s %s %s:%d", dev.UUID, dev.Name, dev.Host.String(), dev.Port) } return nil }, } }