From 623c7e65b6fc7aeb71909c016de06e9cf324256c Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 29 Aug 2017 20:56:52 +0200 Subject: some cleanup and enhancements of EXAMPLES --- EXAMPLES | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 11 deletions(-) diff --git a/EXAMPLES b/EXAMPLES index 4d5b375..c18382b 100644 --- a/EXAMPLES +++ b/EXAMPLES @@ -1,25 +1,88 @@ -TODO: clean this up a bit +## Eventually I'd like to make calendar-cli easier to use, so some of the "external logic" in those examples will eventually be moved into the tool itself. Anyway, some of the power of having a command-line utility is that it's possible to do just anything ... -Eventually I'd like to make calendar-cli easier to use, so some of the "external logic" in those examples will eventually be moved into the tool itself. Anyway, some of the power of having a command-line utility is that it's possible to do just anything ... +## TODO: still some hard-coded personal stuff in the script. Should move it out to a config section. + +[ -z "$EDITOR" ] && EDITOR=vi + +## Simple sync of a google calendar into personal calendar +wget -O- https://www.google.com/calendar/ical/gsmk.gcal%40gmail.com/public/basic.ics | calendar-cli calendar addics + +echo "Enter a category or enter for all:" +read category +if [ -n "$category" ] +then + selflags="--categories=$category" +fi ## Take out a personal agenda from different calendar sources: -for section in pp seb house default work holidays ; do ./calendar-cli.py --config-section $section calendar agenda --agenda-days 20; done | sort ; for section in seb house default work-tasks pp-tasks ; do echo $section; ./calendar-cli.py --config-section $section todo --limit 10 --hide-parent list ; done ## AGENDA + +echo "Here is your upcoming calendar events:" +for section in pp seb house default work holidays +do + calendar-cli --config-section $section calendar agenda --agenda-days 20 +done | sort + +echo -e "\nAnd here is your upcoming calendar tasks:" +for section in seb house default work-tasks pp-tasks +do + echo $section + calendar-cli --config-section $section todo $selflags --limit 10 --hide-parent list +done + ## Interactively set categories on uncategorized tasks: -cd ~/calendar-cli/ ; { ./calendar-cli.py todo list --list-categories | perl -pe 's/^/# /' ; ./calendar-cli.py todo --nocategories list --todo-template='./calendar-cli.py todo --todo-uid={uid} edit --set-categories=foo # {summary}' ; } > /tmp/nocat ; $EDITOR /tmp/nocat ; . /tmp/nocat +tempfile=$(mktemp) +calendar-cli todo --nocategories list --todo-template='calendar-cli todo --todo-uid={uid} edit --set-categories=foo # {summary}' > $tempfile +if [ -s $tempfile ] +then + ## We have non-categorized tasks + echo -e "\nNext up: categorization of uncategorized tasks. Press enter" + read + tempfile2=$(mktemp) + ## Populate the tempfile with the list of categories first + calendar-cli todo list --list-categories | perl -pe 's/^/# /' > $tempfile2 + cat $tempfile >> $tempfile2 + while grep -q -- '--set-categories=foo ' $tempfile2 + do + $EDITOR $tempfile2 + done + . $tempfile2 +else + echo "No uncategorized todo-items on the calendar. Good!" +fi +rm $tempfile2 + ## Interactively mark tasks as completed: -cd ~/calendar-cli/ ; { ./calendar-cli.py todo --hide-parents --limit 10 list --todo-template='# ./calendar-cli.py todo --todo-uid={uid} complete # {summary}' ; } > /tmp/tocomplete ; $EDITOR /tmp/tocomplete ; . /tmp/tocomplete +calendar-cli todo --selflags --hide-parents --limit 10 list --todo-template='# calendar-cli todo --todo-uid={uid} complete # {summary}' > $tempfile +## Exit if there aren't any tasks +if [ ! -s $tempfile ] + echo "No tasks available. Good?" + exit 0 +fi -## Interactively mark tasks as completed, with category: -CAT=keyboard ; cd ~/calendar-cli/ ; { ./calendar-cli.py todo --hide-parents --categories=$CAT --limit 10 list --todo-template='# ./calendar-cli.py todo --todo-uid={uid} complete # {summary}' ; } > /tmp/tocomplete ; $EDITOR /tmp/tocomplete ; . /tmp/tocomplete +echo -e "\nNext up: Mark tasks that are completed as completed. Press enter" +read +$EDITOR $tempfile +. $tempfile ## Set more realistic due-dates on overdue tasks -cd ~/calendar-cli/ ; { ./calendar-cli.py todo --overdue list --todo-template='./calendar-cli.py todo --todo-uid={uid} postpone --due "in 2d" # {summary}' ; } > /tmp/toprocrastinate ; $EDITOR /tmp/toprocrastinate ; . /tmp/toprocrastinate +calendar-cli todo --overdue list --todo-template='calendar-cli todo --todo-uid={uid} postpone --due "in 4d" # {summary}' > $tempfile +if [ -s $tempfile ] +then + echo -e "\nNext up: Look over overdue tasks and consider procrastinating some of them. Press enter" + $EDITOR $tempfile + . $tempfile +fi ## Clean the list a bit by procrastinating tasks (this includes the overdue) -cd ~/calendar-cli/ ; { ./calendar-cli.py todo --hide-future list --todo-template='./calendar-cli.py todo --todo-uid={uid} postpone "in 5d" # {summary}' ; } > /tmp/toprocrastinate ; $EDITOR /tmp/toprocrastinate ; . /tmp/toprocrastinate +calendar-cli todo --hide-future list --todo-template='calendar-cli todo --todo-uid={uid} postpone "in 4d" # {summary}' > $tempfile +if [ -s $tempfile ] +then + echo -e "\nNext up: Consider procrastinating the start-date of some of the tasks on your list. Press enter" + $EDITOR $tempfile + . $tempfile +fi -## Simple sync of a google calendar into personal calendar -wget -O- https://www.google.com/calendar/ical/gsmk.gcal%40gmail.com/public/basic.ics | calendar-cli calendar addics +echo "Done!" -- cgit v1.2.3 From e4b75877bde487d23d4d39de331c099659522453 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Wed, 30 Aug 2017 00:30:06 +0200 Subject: bugfixes --- EXAMPLES | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/EXAMPLES b/EXAMPLES index c18382b..0a770bf 100644 --- a/EXAMPLES +++ b/EXAMPLES @@ -17,13 +17,13 @@ fi ## Take out a personal agenda from different calendar sources: echo "Here is your upcoming calendar events:" -for section in pp seb house default work holidays +for section in pir seb house default work holidays do calendar-cli --config-section $section calendar agenda --agenda-days 20 done | sort echo -e "\nAnd here is your upcoming calendar tasks:" -for section in seb house default work-tasks pp-tasks +for section in seb house default work-tasks pir-tasks do echo $section calendar-cli --config-section $section todo $selflags --limit 10 --hide-parent list @@ -54,9 +54,10 @@ rm $tempfile2 ## Interactively mark tasks as completed: -calendar-cli todo --selflags --hide-parents --limit 10 list --todo-template='# calendar-cli todo --todo-uid={uid} complete # {summary}' > $tempfile +calendar-cli todo $selflags --hide-parents --limit 10 list --todo-template='# calendar-cli todo --todo-uid={uid} complete # {summary}' > $tempfile ## Exit if there aren't any tasks if [ ! -s $tempfile ] +then echo "No tasks available. Good?" exit 0 fi @@ -71,6 +72,7 @@ calendar-cli todo --overdue list --todo-template='calendar-cli todo --todo-uid={ if [ -s $tempfile ] then echo -e "\nNext up: Look over overdue tasks and consider procrastinating some of them. Press enter" + read $EDITOR $tempfile . $tempfile fi @@ -80,6 +82,7 @@ calendar-cli todo --hide-future list --todo-template='calendar-cli todo --todo-u if [ -s $tempfile ] then echo -e "\nNext up: Consider procrastinating the start-date of some of the tasks on your list. Press enter" + read $EDITOR $tempfile . $tempfile fi -- cgit v1.2.3 From 4df23c9f0e4be45a4a053cb290d2533516cb0e85 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Wed, 30 Aug 2017 00:31:41 +0200 Subject: fix proper command name, fix dependency, compatibility fix on version number, modified defaults to fit with my workflow - due dates should expire immediately by default so we can set a proper due date --- calendar-cli | 1 + calendar-cli.py | 6 +++--- calendar_cli.py | 1 + setup.py | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) create mode 120000 calendar-cli create mode 120000 calendar_cli.py diff --git a/calendar-cli b/calendar-cli new file mode 120000 index 0000000..e3b7ab8 --- /dev/null +++ b/calendar-cli @@ -0,0 +1 @@ +calendar-cli.py \ No newline at end of file diff --git a/calendar-cli.py b/calendar-cli.py index cd6a2ec..9398942 100755 --- a/calendar-cli.py +++ b/calendar-cli.py @@ -34,7 +34,7 @@ import logging import sys import re -__version__ = "0.11.0-dev" +__version__ = "0.11.0.dev0" __author__ = "Tobias Brox" __author_short__ = "tobixen" __copyright__ = "Copyright 2013-2016, Tobias Brox" @@ -761,8 +761,8 @@ def main(): todo_subparsers = todo_parser.add_subparsers(title='tasks subcommand') todo_add_parser = todo_subparsers.add_parser('add') todo_add_parser.add_argument('summaryline', nargs='+') - todo_add_parser.add_argument('--set-due', default=date.today()+timedelta(365)) todo_add_parser.add_argument('--set-dtstart', default=date.today()+timedelta(1)) + todo_add_parser.add_argument('--set-due', default=date.today()+timedelta(1)) todo_add_parser.add_argument('--is-child', help="the new task is a child-task of the selected task(s)", action='store_true') for attr in vtodo_txt_one + vtodo_txt_many: if attr != 'summary': @@ -775,7 +775,7 @@ def main(): todo_list_parser = todo_subparsers.add_parser('list') todo_list_parser.add_argument('--todo-template', help="Template for printing out the event", default="{dtstart}{dtstart_passed_mark} {due}{due_passed_mark} {summary}") - todo_list_parser.add_argument('--default-due', help="Default number of days from a task is submitted until it's considered due", type=int, default=365) + todo_list_parser.add_argument('--default-due', help="Default number of days from a task is submitted until it's considered due", type=int, default=14) todo_list_parser.add_argument('--list-categories', help="Instead of listing the todo-items, list the unique categories used", action='store_true') todo_list_parser.add_argument('--timestamp-format', help="strftime-style format string for the output timestamps", default="%F (%a)") todo_list_parser.set_defaults(func=todo_list) diff --git a/calendar_cli.py b/calendar_cli.py new file mode 120000 index 0000000..e3b7ab8 --- /dev/null +++ b/calendar_cli.py @@ -0,0 +1 @@ +calendar-cli.py \ No newline at end of file diff --git a/setup.py b/setup.py index 260921e..a843a49 100644 --- a/setup.py +++ b/setup.py @@ -37,10 +37,10 @@ setup( "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries", ], - scripts=['calendar-cli.py'], + scripts=['calendar-cli.py', 'calendar-cli'], install_requires=[ 'icalendar', - 'caldav>=0.4.0.dev', + 'caldav>=0.5.0', 'pytz', 'tzlocal' ], -- cgit v1.2.3 From 7e468a976711c4fcaed95cc6f0ca55983518e89c Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Wed, 30 Aug 2017 21:51:54 +0200 Subject: bugfixing --- EXAMPLES | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/EXAMPLES b/EXAMPLES index 0a770bf..97b7c8b 100644 --- a/EXAMPLES +++ b/EXAMPLES @@ -4,9 +4,6 @@ [ -z "$EDITOR" ] && EDITOR=vi -## Simple sync of a google calendar into personal calendar -wget -O- https://www.google.com/calendar/ical/gsmk.gcal%40gmail.com/public/basic.ics | calendar-cli calendar addics - echo "Enter a category or enter for all:" read category if [ -n "$category" ] @@ -47,10 +44,10 @@ then $EDITOR $tempfile2 done . $tempfile2 + rm $tempfile2 else echo "No uncategorized todo-items on the calendar. Good!" fi -rm $tempfile2 ## Interactively mark tasks as completed: @@ -87,5 +84,9 @@ then . $tempfile fi +## Simple sync of a google calendar into personal calendar +wget -O- https://www.google.com/calendar/ical/gsmk.gcal%40gmail.com/public/basic.ics | calendar-cli calendar addics + + echo "Done!" -- cgit v1.2.3 From bb12a1dc830b5837ac10328c6d90f3d62342bcd3 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 30 Oct 2017 14:42:03 +0100 Subject: the information in this file was rather obsoleted --- INSTALL.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a916765..bc67ddf 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,11 +1,4 @@ Installing the calendar-cli =========================== -No packaging available yet; it's just to copy the python executable into the path, i.e. /usr/local/bin - -There are two dependencies; - -* icalendar library - I've used https://pypi.python.org/pypi/icalendar -* caldav library - I've used http://trac.calendarserver.org/wiki/CalDAVClientLibrary - but I'm strongly considering to switch to https://pypi.python.org/pypi/caldav - -All of those are under development and has to be installed manually. +"sudo ./setup.py install" should just work \ No newline at end of file -- cgit v1.2.3