Skip to content

Add --json output option#832

Merged
dbarnett merged 5 commits intoinsanum:mainfrom
kitlaan:add-json-output
Apr 27, 2025
Merged

Add --json output option#832
dbarnett merged 5 commits intoinsanum:mainfrom
kitlaan:add-json-output

Conversation

@kitlaan
Copy link
Copy Markdown
Contributor

@kitlaan kitlaan commented Apr 7, 2025

This PR extends the --tsv output mechanism to provide an alternative --json output format.
Implements #466

For consistency, anywhere where there's a json dict, the key names use the TSV column name.

As part of this,

  • plumbed attendees detail handlers. (attendees for TSV is semi-colon delimited email addresses)
  • fixed some subclasses?
  • email is more tolerant of creator/organizer

keys = set(self.details.keys())
keys.update(DETAILS_DEFAULT)

print("[")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why print out the list characters manually instead of printing a list converted to JSON?

If it's for pretty printing, json.dumps accepts an indent arg to output pretty-printed JSON (with new lines indented to a certain width).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to avoid keeping all the rows in memory.

All we're doing is outputting to stdout, so it seemed more prudent to stream each row instead of buffering.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, felt a little low-level to optimize for stdout but I guess that's how a lot of other code here is too.

@dbarnett dbarnett merged commit 91db693 into insanum:main Apr 27, 2025
10 checks passed
kda pushed a commit to kda/gcalcli that referenced this pull request Jan 7, 2026
* Extend Handler to allow unformatted output

* Fix class inheritance

* Implement Conference Handler

* Implement Attendees Handler

* Add json outputter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants