From 41e3969a293e416bf3561522f5407437d864f0ee Mon Sep 17 00:00:00 2001 From: Adam Saponara Date: Thu, 16 Apr 2026 15:43:21 +0000 Subject: [PATCH] Add `--only-accepted` to remind command --- gcalcli/argparsers.py | 6 ++++++ gcalcli/cli.py | 3 ++- gcalcli/gcal.py | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gcalcli/argparsers.py b/gcalcli/argparsers.py index 023a338e..e4b10159 100644 --- a/gcalcli/argparsers.py +++ b/gcalcli/argparsers.py @@ -707,6 +707,12 @@ def get_argument_parser(): '--use_reminders', action=DeprecatedStoreTrue, help=argparse.SUPPRESS ) + remind.add_argument( + '--only-accepted', + action='store_true', + help='Only remind for accepted or tentatively accepted events', + ) + config = sub.add_parser( 'config', help='utility commands to work with configuration', diff --git a/gcalcli/cli.py b/gcalcli/cli.py index 5f7ad1da..6dcf5187 100755 --- a/gcalcli/cli.py +++ b/gcalcli/cli.py @@ -328,7 +328,8 @@ def main(): elif parsed_args.command == 'remind': gcal.Remind( parsed_args.minutes, parsed_args.cmd, - use_reminders=parsed_args.use_reminders + use_reminders=parsed_args.use_reminders, + only_accepted=parsed_args.only_accepted ) elif parsed_args.command == 'import': diff --git a/gcalcli/gcal.py b/gcalcli/gcal.py index c8fb52f0..742891cc 100644 --- a/gcalcli/gcal.py +++ b/gcalcli/gcal.py @@ -1512,7 +1512,8 @@ def ModifyEvents(self, work, search_text, start=None, end=None, return self._iterate_events( self.now, event_list, year_date=True, work=work) - def Remind(self, minutes, command, use_reminders=False): + def Remind(self, minutes, command, use_reminders=False, + only_accepted=False): """ Check for events between now and now+minutes. @@ -1542,6 +1543,18 @@ def Remind(self, minutes, command, use_reminders=False): # don't remind if all reminders haven't arrived yet continue + # if only_accepted, skip if self not accepted or tentative + if only_accepted: + if 'attendees' not in event: + continue + attendee_self = next((a for a in event['attendees'] \ + if 'self' in a and a['self']), None) + if not attendee_self \ + or 'responseStatus' not in attendee_self \ + or attendee_self['responseStatus'] not in \ + ['accepted', 'tentative']: + continue + if self.options.get('military'): tmp_time_str = event['s'].strftime('%H:%M') else: