From e73ec3aab27461039673a58c7ade8e6a9e878c43 Mon Sep 17 00:00:00 2001 From: Christian Geier Date: Tue, 31 Oct 2023 00:28:15 +0100 Subject: [PATCH 1/2] update json doc formatting --- doc/source/usage.rst | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/doc/source/usage.rst b/doc/source/usage.rst index a1c2f67d2..dfac789bc 100644 --- a/doc/source/usage.rst +++ b/doc/source/usage.rst @@ -209,9 +209,7 @@ Several options are common to almost all of :program:`khal`'s commands Works similar to :option:`--format`, but instead of defining a format string a JSON object is created for each specified field. The matching events are collected into a JSON array. This option accepts the following subset of :option:`--format` - template options - - :: + template options:: title, description, uid, start, start-long, start-date, start-date-long, start-time, end, end-long, end-date, @@ -233,7 +231,7 @@ Several options are common to almost all of :program:`khal`'s commands Below is an example command which prints a JSON list of objects containing the title and description of all events today. - :: + .. code-block:: console khal list --json title --json description @@ -275,8 +273,7 @@ Commands list **** shows all events scheduled for a given date (or datetime) range, with custom -formatting: -:: +formatting:: khal list [-a CALENDAR ... | -d CALENDAR ...] [--format FORMAT] [--json FIELD ...] [--day-format DAYFORMAT] From 3b4e0241f264e280bbce2aaa203d6913074fcb94 Mon Sep 17 00:00:00 2001 From: Christian Geier Date: Tue, 31 Oct 2023 00:28:23 +0100 Subject: [PATCH 2/2] simplying json code path --- khal/controllers.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/khal/controllers.py b/khal/controllers.py index a850b33c8..acedf9c09 100644 --- a/khal/controllers.py +++ b/khal/controllers.py @@ -255,8 +255,7 @@ def khal_list( if agenda_format is None: agenda_format = conf['view']['agenda_event_format'] - json_mode = json is not None and len(json) > 0 - if json_mode: + if json: formatter = json_formatter(json) colors = False else: @@ -313,7 +312,7 @@ def khal_list( seen=once, colors=colors, ) - if day_format and (conf['default']['show_all_days'] or current_events) and not json_mode: + if day_format and (conf['default']['show_all_days'] or current_events) and not json: if len(event_column) != 0 and conf['view']['blank_line_before_day']: event_column.append('') event_column.append(format_day(start.date(), day_format, conf['locale']))