@@ -76,12 +76,17 @@ var (
7676 Flags : []cli.Flag {
7777 & cli.IntFlag {
7878 Name : "limit" ,
79- Usage : "Maximum number of results (default: 50)" ,
79+ Usage : "Maximum number of results per page (default: 50)" ,
8080 Value : 50 ,
8181 },
82+ & cli.IntFlag {
83+ Name : "offset" ,
84+ Usage : "Offset for pagination (default: 0)" ,
85+ Value : 0 ,
86+ },
8287 & cli.StringSliceFlag {
8388 Name : "status" ,
84- Usage : "Filter by status(es) (active, pending, released). Mutliple values can be specified." ,
89+ Usage : "Filter by status(es) (active, pending, released, offline ). Multiple values can be specified." ,
8590 },
8691 & cli.StringFlag {
8792 Name : "sip-dispatch-rule-id" ,
@@ -351,10 +356,17 @@ func listPhoneNumbers(ctx context.Context, cmd *cli.Command) error {
351356 }
352357
353358 req := & livekit.ListPhoneNumbersRequest {}
354- if val := cmd .Int ("limit" ); val != 0 {
355- limit := int32 (val )
356- req .Limit = & limit
359+ limit := int32 (cmd .Int ("limit" ))
360+ offset := int32 (cmd .Int ("offset" ))
361+
362+ // Encode offset and limit into a page token for pagination
363+ // Even if offset is 0, we encode it to include the limit in the token
364+ pageToken , err := livekit .EncodeTokenPagination (offset , limit )
365+ if err != nil {
366+ return fmt .Errorf ("failed to encode pagination token: %w" , err )
357367 }
368+ req .PageToken = pageToken
369+
358370 if statuses := cmd .StringSlice ("status" ); len (statuses ) > 0 {
359371 var phoneNumberStatuses []livekit.PhoneNumberStatus
360372 for _ , status := range statuses {
@@ -418,7 +430,23 @@ func listPhoneNumbers(ctx context.Context, cmd *cli.Command) error {
418430 return nil
419431 }
420432
421- fmt .Printf ("Total phone numbers: %d\n " , resp .TotalCount )
433+ fmt .Printf ("Total phone numbers: %d" , resp .TotalCount )
434+ if resp .OfflineCount > 0 {
435+ fmt .Printf (" (%d offline)" , resp .OfflineCount )
436+ }
437+ fmt .Printf ("\n " )
438+
439+ // Show pagination info
440+ if offset > 0 {
441+ fmt .Printf ("Showing results from offset %d\n " , offset )
442+ }
443+ if resp .NextPageToken != nil {
444+ nextOffset , _ , err := livekit .DecodeTokenPagination (resp .NextPageToken )
445+ if err == nil {
446+ fmt .Printf ("More results available. Use --offset %d to see the next page.\n " , nextOffset )
447+ }
448+ }
449+
422450 return listAndPrint (ctx , cmd , func (ctx context.Context , req * livekit.ListPhoneNumbersRequest ) (* livekit.ListPhoneNumbersResponse , error ) {
423451 return client .ListPhoneNumbers (ctx , req )
424452 }, req , []string {
0 commit comments