Skip to content

Instantly share code, notes, and snippets.

@cyphunk
Created May 12, 2015 10:21
Show Gist options
  • Save cyphunk/7e9257e6d81ce3fc230d to your computer and use it in GitHub Desktop.
Save cyphunk/7e9257e6d81ce3fc230d to your computer and use it in GitHub Desktop.
provides start and end support for delete command
diff --git a/gcalcli b/gcalcli
index c063c97..960cd23 100755
--- a/gcalcli
+++ b/gcalcli
@@ -1760,13 +1760,13 @@ class gcalcli:
hLink = self._ShortenURL(newEvent['htmlLink'])
PrintMsg(CLR_GRN(), 'New event added: %s\n' % hLink)
- def DeleteEvents(self, searchText='', expert=False):
+ def DeleteEvents(self, searchText='', expert=False, start=None, end=None):
# the empty string would get *ALL* events...
if searchText == '':
return
- eventList = self._SearchForCalEvents(None, None, searchText)
+ eventList = self._SearchForCalEvents(start, end, searchText)
self.iamaExpert = expert
self._IterateEvents(self.now, eventList,
@@ -2462,13 +2462,22 @@ def BowChickaWowWow():
FLAGS.description, FLAGS.reminder)
elif args[0] == 'delete':
- if len(args) != 2:
+ if len(args) < 2:
PrintErrMsg('Error: invalid search string\n')
sys.exit(1)
+ elif len(args) == 4: # search, start, end
+ eStart = gcal.dateParser.fromString(args[2])
+ eEnd = gcal.dateParser.fromString(args[3])
+ elif len(args) == 3: # search, start (default end)
+ eStart = gcal.dateParser.fromString(args[2])
+ eEnd = gcal.dateParser.fromString("30 days")
+ elif len(args) == 2: # search, (defaults start, end)
+ eStart = gcal.dateParser.fromString("today")
+ eEnd = gcal.dateParser.fromString("30 days")
# allow unicode strings for input
gcal.DeleteEvents(stringToUnicode(args[1]),
- FLAGS.iamaexpert)
+ FLAGS.iamaexpert, eStart, eEnd)
sys.stdout.write('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment