Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support json as an output option for most commands #1308

Merged
merged 35 commits into from
Oct 29, 2023
Merged

Conversation

geier
Copy link
Member

@geier geier commented Oct 27, 2023

Replacement for #1037

This is @PsychicNoodles' work, I just rebased it.

@geier geier requested a review from WhyNotHugo October 27, 2023 20:45
@geier
Copy link
Member Author

geier commented Oct 27, 2023

I rebased the PR (again) and would like to merge it soon. Seems to work, but I'll have a more detailed look.

@geier geier changed the title Feature/json export Support json as an output option for most commands Oct 27, 2023
@geier geier mentioned this pull request Oct 27, 2023
@geier geier force-pushed the feature/json_export branch from b89b7ef to 1d60f78 Compare October 29, 2023 14:59
@geier
Copy link
Member Author

geier commented Oct 29, 2023

I'll merge this now, we can still fix @WhyNotHugo 's comment from last year once it's merged (ideally before the next release though).

@geier geier merged commit 4d4fb9b into master Oct 29, 2023
4 checks passed
@geier geier deleted the feature/json_export branch October 29, 2023 16:13
Comment on lines +212 to +214
template options

::
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
template options
::
template options::

Below is an example command which prints a JSON list of objects containing the title and
description of all events today.

::
Copy link
Member

Choose a reason for hiding this comment

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

I think that this renders a :, right?

Suggested change
::
.. code-block:: python

Comment on lines 278 to 279
formatting:
::
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
formatting:
::
formatting::

Comment on lines +258 to +264
json_mode = json is not None and len(json) > 0
if json_mode:
formatter = json_formatter(json)
colors = False
else:
formatter = human_formatter(agenda_format, width)
colors = True
Copy link
Member

Choose a reason for hiding this comment

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

Passing an empty list is not an expected input here; I wouldn't add complexity in handling it.

If someone does call this function with json=[], the render an empty json objet as requested.

Mostly, I think this is a bit simpler to follow.

Suggested change
json_mode = json is not None and len(json) > 0
if json_mode:
formatter = json_formatter(json)
colors = False
else:
formatter = human_formatter(agenda_format, width)
colors = True
if json is not None:
formatter = json_formatter(json)
colors = False
else:
formatter = human_formatter(agenda_format, width)
colors = True

@WhyNotHugo
Copy link
Member

Ooops. I wrote these comments like a week ago, but apparently never submitted them? I think some are still relevant.

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.

3 participants