calendar-assistant
calendar-assistant copied to clipboard
Structured output
I'd like to be able to extract the list of calendar events into some form of structured output ( so I can import into a spreadsheet for further processing ).
Currently I generate a list like this:
calendar-assistant show [email protected] "2019-01-01..2019-02-01"
[email protected] (all times in Europe/Dublin)
2019-01-02 - 2019-01-05 | XXX treat cases as severity 1 until 1/5/2019 (self)
2019-01-04 22:00 - 23:00 | XXXX 2.1 to 2.2 (Upgrade) (self)
2019-01-07 - 2019-01-09 | XXX Upgrade 2 to 2.1 (not-busy, self)
I'd like to be able to pass a "format" argument to specify the output format - maybe CSV or JSON - eg:
calendar-assistant show [email protected] "2019-01-01..2019-02-01" --format=csv
[email protected] (all times in Europe/Dublin)
start_date,end_date,title
2019-01-02,2019-01-05,"XXX treat cases as severity 1 until 1/5/2019 (self)"
2019-01-04 T22:00,2019-01-04T23:00,"XXXX 2.1 to 2.2 (Upgrade) (self)"
2019-01-07,2019-01-09,"XXX Upgrade 2 to 2.1 (not-busy, self)"
David and I are going to try to pair on this tomorrow.
Thinking about this using the Mikado Method today:
@mikfreedman would love your thoughts on how to approach the solution? Otherwise will hack at it until I find something I'm happy with.
WIP is at branch 123-csv-output
It looks like you're on the right track. I tried to build the presenter nonsense out so that it was swappable at runtime.
you can see the difference in lib/calendar_assistant/cli/commands.rb
#162
def show(datespec = "today")
calendar_assistant(datespec) do |ca, date, out|
event_set = ca.find_events date
out.print_events ca, event_set
end
end
vs an explicit presenter for linting.
#144
def lint(datespec = "today")
calendar_assistant(datespec) do |ca, date, out|
event_set = ca.lint_events date
out.print_events ca, event_set, presenter_class: CalendarAssistant::CLI::LinterEventSetPresenter
end
end
so it should be as simple as fiddling some flags and then writing a new presenter like EventSetPresenter
and LinterEventSetPresenter
. Let me know if you need more info!
FWIW, I was planning to move all list/show event type commands to the same pattern to reduce the logic in cli/commands.rb
and cli/printer.rb
but never got there. If you have the energy maybe take a crack?
@flavorjones ^^