-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
7328e8c
add json option to at command
PsychicNoodles 6667715
added list json formatting
PsychicNoodles d996489
fix color wrap
PsychicNoodles 65a173d
fixed formatting
PsychicNoodles cdb8568
added missing tail reset
PsychicNoodles 322cdc2
fix search formatter usage
PsychicNoodles 43a172f
fixed missing human_formatter
PsychicNoodles c7ef007
fix formatter usage in test
PsychicNoodles c7dc9fa
added colors param to human formatter
PsychicNoodles eb0fdfc
fix formatter usage in test
PsychicNoodles d875a4d
added cli tests
PsychicNoodles 245c105
added json option to search
PsychicNoodles 5062071
moved formatters to util
PsychicNoodles 5955c5d
add json to new
PsychicNoodles bf2062b
corrected style
PsychicNoodles bcd3ced
added test for human_formatter width
PsychicNoodles e4f0cd1
update method docs
PsychicNoodles 747a0c2
update usage doc
PsychicNoodles 02ebf1f
add json feature to changelog
PsychicNoodles 83cd781
rename event.format to event.attributes
PsychicNoodles f3591c6
added special field formatting
PsychicNoodles 4ec1680
added missing formatter
PsychicNoodles 0154b23
add self to authors :)
PsychicNoodles 1ad1b75
add list of content attributes
PsychicNoodles 63d7ffb
added all fields option for json
PsychicNoodles feacba0
fix long lines
PsychicNoodles fbe4c89
fix formatter mistakes
PsychicNoodles 88801e2
remove unnecessary dict call
PsychicNoodles 44d3282
remove mutable default arguments
PsychicNoodles d2e39b1
add to json option docs
PsychicNoodles eb7b1ce
added missing format template options
PsychicNoodles f31faec
typo
PsychicNoodles f4ca976
cli_test format()
geier ef55a88
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1d60f78
make ruff happy
geier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -171,8 +171,21 @@ Several options are common to almost all of :program:`khal`'s commands | |||||||
url-separator | ||||||||
A separator: " :: " that appears when there is a url. | ||||||||
|
||||||||
duration | ||||||||
The duration of the event in terms of days, hours, months, and seconds | ||||||||
(abbreviated to `d`, `h`, `m`, and `s` respectively). | ||||||||
|
||||||||
repeat-pattern | ||||||||
The raw iCal recurrence rule if the event is repeating. | ||||||||
|
||||||||
all-day | ||||||||
A boolean indicating whether it is an all-day event or not. | ||||||||
|
||||||||
categories | ||||||||
The categories of the event. | ||||||||
|
||||||||
By default, all-day events have no times. To see a start and end time anyway simply | ||||||||
add `-full` to the end of any template with start/end, for instance | ||||||||
add `-full` to the end of any template with start/end or duration, for instance | ||||||||
`start-time` becomes `start-time-full` and will always show start and end times (instead | ||||||||
of being empty for all-day events). | ||||||||
|
||||||||
|
@@ -191,6 +204,40 @@ Several options are common to almost all of :program:`khal`'s commands | |||||||
khal list --format "{title} {description}" | ||||||||
|
||||||||
|
||||||||
.. option:: --json FIELD ... | ||||||||
|
||||||||
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 | ||||||||
|
||||||||
:: | ||||||||
|
||||||||
title, description, uid, start, start-long, start-date, | ||||||||
start-date-long, start-time, end, end-long, end-date, | ||||||||
end-date-long, end-time, start-full, start-long-full, | ||||||||
start-date-full, start-date-long-full, start-time-full, | ||||||||
end-full, end-long-full, end-date-full, end-date-long-full, | ||||||||
end-time-full, repeat-symbol, location, calendar, | ||||||||
calendar-color, start-style, to-style, end-style, | ||||||||
start-end-time-style, end-necessary, end-necessary-long, | ||||||||
status, cancelled, organizer, url, duration, duration-full, | ||||||||
repeat-pattern, all-day, categories | ||||||||
|
||||||||
|
||||||||
Note that `calendar-color` will be the actual color name rather than the ANSI color code, | ||||||||
and the `repeat-symbol`, `status`, and `cancelled` values will have leading/trailing | ||||||||
whitespace stripped. Additionally, if only the special value `all` is specified then | ||||||||
all fields will be enabled. | ||||||||
|
||||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I think that this renders a
Suggested change
|
||||||||
|
||||||||
khal list --json title --json description | ||||||||
|
||||||||
|
||||||||
.. option:: --day-format DAYFORMAT | ||||||||
|
||||||||
works similar to :option:`--format`, but for day headings. It only has a few | ||||||||
|
@@ -231,8 +278,9 @@ shows all events scheduled for a given date (or datetime) range, with custom | |||||||
formatting: | ||||||||
:: | ||||||||
Comment on lines
278
to
279
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
khal list [-a CALENDAR ... | -d CALENDAR ...] [--format FORMAT] | ||||||||
[--day-format DAYFORMAT] [--once] [--notstarted] [START [END | DELTA] ] | ||||||||
khal list [-a CALENDAR ... | -d CALENDAR ...] | ||||||||
[--format FORMAT] [--json FIELD ...] [--day-format DAYFORMAT] | ||||||||
[--once] [--notstarted] [START [END | DELTA] ] | ||||||||
|
||||||||
START and END can both be given as dates, datetimes or times (it is assumed | ||||||||
today is meant in the case of only a given time) in the formats configured in | ||||||||
|
@@ -270,7 +318,8 @@ start. | |||||||
|
||||||||
:: | ||||||||
|
||||||||
khal at [-a CALENDAR ... | -d CALENDAR ...] [--format FORMAT] | ||||||||
khal at [-a CALENDAR ... | -d CALENDAR ...] | ||||||||
[--format FORMAT] [--json FIELD ...] | ||||||||
[--notstarted] [[START DATE] TIME | now] | ||||||||
|
||||||||
calendar | ||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.