insanum / gcalcli

Google Calendar Command Line Interface
MIT License
3.31k stars 311 forks source link

Exposing gcalcli as an API to other programming languages (maybe using JSON) #466

Open aindilis opened 5 years ago

aindilis commented 5 years ago

I have a large system written in Perl / Prolog that I'm trying to sync with GCal, and I was unable to get the GCal clients for Perl to work, when I came across gcalcli, which worked great! Thank you! I am wondering is there a way to programmatically access gcalcli, such as via a RESTful API, or via a wrapper, or something. I would like to avoid parsing the STDOUT of the gcalcli CLI program, but if I have to, are there ways to have it dump the entire event spec, hopefully in JSON, etc. I know very little Python.

jcrowgey commented 5 years ago

Well, gcalcli is aimed at exposing the data from the google calendar API to a cli environment. I think that if you want api access, depending on what you're trying to do, it may be easier to just to write your own query to the google calendar api. That said, what you ask for is not totally out of the question, maybe just a little bit surprising.

At this moment, there's no json output option built into the program. Depending on what information you're trying to extract, the --tsv option may give you something close enough. Alternatively, the json package is in the Python standard library, so hacking json.dumps(event) into the code somewhere shouldn't be hard.

I'd be interested in a json output PR if you make something nice.

shaicoleman commented 2 years ago

You'd might want to use google-calendar3-cli for that purpose

dbarnett commented 2 weeks ago

Yeah, if anyone has use cases for things they'd like to do programmatically like this from python, I could take a look and think over options. IMO it's at least worth documenting any good related libraries if not exposing our own.

Does anyone know if https://github.com/Byron/google-apis-rs/tree/main/gen/calendar3-cli is easy to use as a dep of a python project or in other cases where someone might want programmatic APIs? From a glance I'd guess you'd use it by invoking an executable, not importing a library, but that may be a fine approach depending on what someone's wanting to do with it.