@@ -145,6 +145,7 @@ func listSelectedCalendarsEvents(ctx context.Context, svc *calendar.Service, cal
145145func listCalendarIDsEvents (ctx context.Context , svc * calendar.Service , calendarIDs []string , from , to string , maxResults int64 , page string , allPages bool , failEmpty bool , query , privatePropFilter , sharedPropFilter , fields string , showWeekday bool , showLocation bool , timezoneHints map [string ]calendarTimezoneHint , sortKey , sortOrder string ) error {
146146 u := ui .FromContext (ctx )
147147 all := []* eventWithCalendar {}
148+ nextPages := []calendarEventsNextPage {}
148149 for _ , calID := range calendarIDs {
149150 calID = strings .TrimSpace (calID )
150151 if calID == "" {
@@ -159,11 +160,17 @@ func listCalendarIDsEvents(ctx context.Context, svc *calendar.Service, calendarI
159160 return resp .Items , resp .NextPageToken , nil
160161 }
161162
162- events , _ , err := loadPagedItems (page , allPages , fetch )
163+ events , nextPageToken , err := loadPagedItems (page , allPages , fetch )
163164 if err != nil {
164165 u .Err ().Linef ("calendar %s: %v" , calID , err )
165166 continue
166167 }
168+ if nextPageToken != "" {
169+ nextPages = append (nextPages , calendarEventsNextPage {
170+ CalendarID : calID ,
171+ NextPageToken : nextPageToken ,
172+ })
173+ }
167174
168175 for _ , e := range events {
169176 redactCalendarEventForOutput (ctx , e )
@@ -182,7 +189,31 @@ func listCalendarIDsEvents(ctx context.Context, svc *calendar.Service, calendarI
182189 }
183190 return nil
184191 }
185- return renderCalendarEventsTable (ctx , all , "" , true , showWeekday , showLocation , failEmpty , false )
192+ if err := renderCalendarEventsTable (ctx , all , "" , true , showWeekday , showLocation , failEmpty , false ); err != nil {
193+ return err
194+ }
195+ printCalendarEventsNextPageHint (u , len (calendarIDs ), nextPages )
196+ return nil
197+ }
198+
199+ type calendarEventsNextPage struct {
200+ CalendarID string
201+ NextPageToken string
202+ }
203+
204+ func printCalendarEventsNextPageHint (u * ui.UI , calendarCount int , nextPages []calendarEventsNextPage ) {
205+ if u == nil || len (nextPages ) == 0 {
206+ return
207+ }
208+ if calendarCount == 1 {
209+ printNextPageHintWithAll (u , nextPages [0 ].NextPageToken , "--all-pages" )
210+ return
211+ }
212+ if len (nextPages ) == 1 {
213+ u .Err ().Linef ("# More results: use --all-pages to fetch every page (%s has more results)" , nextPages [0 ].CalendarID )
214+ return
215+ }
216+ u .Err ().Linef ("# More results: use --all-pages to fetch every page (%d calendars have more results)" , len (nextPages ))
186217}
187218
188219func renderCalendarEventsTable (ctx context.Context , events []* eventWithCalendar , nextPageToken string , includeCalendar , showWeekday , showLocation , failEmpty bool , printPageHint bool ) error {
0 commit comments