@@ -103,9 +103,11 @@ var (
103103 Usage : "Limits list to a certain room `NAME`" ,
104104 },
105105 & cli.BoolFlag {
106- Name : "active" ,
107- Usage : "Lists only active egresses" ,
106+ Name : "active" ,
107+ Aliases : []string {"a" },
108+ Usage : "Lists only active egresses" ,
108109 },
110+ jsonFlag ,
109111 },
110112 },
111113 {
@@ -595,48 +597,52 @@ func listEgress(ctx context.Context, cmd *cli.Command) error {
595597 items = res .Items
596598 }
597599
598- table := CreateTable ().
599- Headers ("EgressID" , "Status" , "Type" , "Source" , "Started At" , "Error" )
600- for _ , item := range items {
601- var startedAt string
602- if item .StartedAt != 0 {
603- startedAt = fmt .Sprint (time .Unix (0 , item .StartedAt ))
604- }
605- var egressType , egressSource string
606- switch req := item .Request .(type ) {
607- case * livekit.EgressInfo_RoomComposite :
608- egressType = "room_composite"
609- egressSource = req .RoomComposite .RoomName
610- case * livekit.EgressInfo_Web :
611- egressType = "web"
612- egressSource = req .Web .Url
613- case * livekit.EgressInfo_Participant :
614- egressType = "participant"
615- egressSource = fmt .Sprintf ("%s/%s" , req .Participant .RoomName , req .Participant .Identity )
616- case * livekit.EgressInfo_TrackComposite :
617- egressType = "track_composite"
618- trackIDs := make ([]string , 0 )
619- if req .TrackComposite .VideoTrackId != "" {
620- trackIDs = append (trackIDs , req .TrackComposite .VideoTrackId )
600+ if cmd .Bool ("json" ) {
601+ PrintJSON (items )
602+ } else {
603+ table := CreateTable ().
604+ Headers ("EgressID" , "Status" , "Type" , "Source" , "Started At" , "Error" )
605+ for _ , item := range items {
606+ var startedAt string
607+ if item .StartedAt != 0 {
608+ startedAt = fmt .Sprint (time .Unix (0 , item .StartedAt ))
621609 }
622- if req .TrackComposite .AudioTrackId != "" {
623- trackIDs = append (trackIDs , req .TrackComposite .AudioTrackId )
610+ var egressType , egressSource string
611+ switch req := item .Request .(type ) {
612+ case * livekit.EgressInfo_RoomComposite :
613+ egressType = "room_composite"
614+ egressSource = req .RoomComposite .RoomName
615+ case * livekit.EgressInfo_Web :
616+ egressType = "web"
617+ egressSource = req .Web .Url
618+ case * livekit.EgressInfo_Participant :
619+ egressType = "participant"
620+ egressSource = fmt .Sprintf ("%s/%s" , req .Participant .RoomName , req .Participant .Identity )
621+ case * livekit.EgressInfo_TrackComposite :
622+ egressType = "track_composite"
623+ trackIDs := make ([]string , 0 )
624+ if req .TrackComposite .VideoTrackId != "" {
625+ trackIDs = append (trackIDs , req .TrackComposite .VideoTrackId )
626+ }
627+ if req .TrackComposite .AudioTrackId != "" {
628+ trackIDs = append (trackIDs , req .TrackComposite .AudioTrackId )
629+ }
630+ egressSource = fmt .Sprintf ("%s/%s" , req .TrackComposite .RoomName , strings .Join (trackIDs , "," ))
631+ case * livekit.EgressInfo_Track :
632+ egressType = "track"
633+ egressSource = fmt .Sprintf ("%s/%s" , req .Track .RoomName , req .Track .TrackId )
624634 }
625- egressSource = fmt .Sprintf ("%s/%s" , req .TrackComposite .RoomName , strings .Join (trackIDs , "," ))
626- case * livekit.EgressInfo_Track :
627- egressType = "track"
628- egressSource = fmt .Sprintf ("%s/%s" , req .Track .RoomName , req .Track .TrackId )
635+ table .Row (
636+ item .EgressId ,
637+ item .Status .String (),
638+ egressType ,
639+ egressSource ,
640+ startedAt ,
641+ item .Error ,
642+ )
629643 }
630- table .Row (
631- item .EgressId ,
632- item .Status .String (),
633- egressType ,
634- egressSource ,
635- startedAt ,
636- item .Error ,
637- )
638- }
639- fmt .Println (table )
644+ fmt .Println (table )
645+ }
640646
641647 return nil
642648}
0 commit comments