[Remind-Fans] Improvements to json output

Jochen Sprickerhof remind at jochen.sprickerhof.de
Fri Aug 5 02:58:33 EDT 2022


Hi Dianne,

I've been working on json parsing in wyrd lately and got some ideas how 
to improve the output. I can work on patches but wanted to hear first if 
you are open to change the format at all and how to do it best.
First, I can get all the information I need but I have to do extra 
parsing which would be great to avoid and would make it easer for others 
to adopt the format. Also we can decide if we want to do the changes in 
a backward compatible way by adding new keys or not by changing the 
current ones.

# Remove color and time information from "body"

$ echo 'REM AT 1:00 DURATION 2:00 SPECIAL COLOR 255 1 1 [$T]' | remind -ppp -
[..]
       {
         "date": "2022-08-31",
         "filename": "-",
         "lineno": 1,
         "passthru": "COLOR",
         "duration": 120,
         "time": 60,
         "eventduration": 120,
         "eventstart": "2022-08-31T01:00",
         "priority": 5000,
         "r": 255,
         "g": 1,
         "b": 1,
         "rawbody": "[$T]",
         "body": "255 1 1 1:00-3:00am 2022-08-31"
       }


The color information in the "body" ("255 1 1") is already in r, g and b 
and should not be part of the displayed message. Obviously we don't want 
to show the rawbody either.
Same for the "1:00am-3:00am", which is already available in time and 
duration.
Also duration and eventduration and date and eventstart seem duplicate.


# Provide calendar and non calendar message in separate keys

Some time ago you added -pppq to get the full message instead of the 
calendar version:

$ echo 'REM MSG %"calendar%" additional text' | remind -pppq -
[..]
       {
         "date": "2022-08-31",
         "filename": "-",
         "lineno": 1,
         "priority": 5000,
         "body": "%\"calendar%\" additional text"
       }
It would be great if Remind would provide both parts in separated keys, 
say: {"summary": "calendar", "description": "additional text"}, so 
consuming tools would not need to know about the Remind format. That's 
also what I use in python-remind: 

https://github.com/jspricke/python-remind#format-of-the-remind-msg-body


# "d", "m" and "y" stay at event start

$ echo 'REM Jan 1 2022 *1 UNTIL Jan 31 2022 MSG Foo' | remind -ppp - 2022-01-01
[..]
       {
         "date": "2022-01-31",
         "filename": "-",
         "lineno": 1,
         "d": 1,
         "m": 1,
         "y": 2022,
         "rep": 1,
         "until": "2022-01-31",
         "priority": 5000,
         "body": "Foo"
       }

I think "d" should be 31 in this example. Currently I have to parse 
"date" to find out where to show this event.


# boilerplate

Last, there is a lot of boilerplate in the json where I'm not sure if it 
is useful:

$ echo '' | remind -ppp -
[
   {
     "monthname": "August",
     "year": 2022,
     "daysinmonth": 31,
     "firstwkday": 1,
     "mondayfirst": 0,
     "daynames": [
       "Sunday",
       "Monday",
       "Tuesday",
       "Wednesday",
       "Thursday",
       "Friday",
       "Saturday"
     ],
     "prevmonthname": "July",
     "daysinprevmonth": 31,
     "prevmonthyear": 2022,
     "nextmonthname": "September",
     "daysinnextmonth": 30,
     "nextmonthyear": 2022,
     "entries": []
   }
]

I guess that it makes some tools (tkremind?) easier but I don't think it 
should be part of the generic output as it can be computed in the tool. 
I would propose to only return they content of the "entries" key.

Just to repeat, I have no problem with working around all this so this 
is rather a wishlist and ideas collection.

Cheers Jochen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://dianne.skoll.ca/pipermail/remind-fans/attachments/20220805/c5c64e17/attachment.sig>


More information about the Remind-fans mailing list