-
Notifications
You must be signed in to change notification settings - Fork 209
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
Conversation
I rebased the PR (again) and would like to merge it soon. Seems to work, but I'll have a more detailed look. |
for more information, see https://pre-commit.ci
b89b7ef
to
1d60f78
Compare
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). |
template options | ||
|
||
:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. | ||
|
||
:: |
There was a problem hiding this comment.
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?
:: | |
.. code-block:: python |
formatting: | ||
:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting: | |
:: | |
formatting:: |
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 |
There was a problem hiding this comment.
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.
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 |
Ooops. I wrote these comments like a week ago, but apparently never submitted them? I think some are still relevant. |
Replacement for #1037
This is @PsychicNoodles' work, I just rebased it.