Creating Status Hero Reports from Org mode

Written by Torstein Krause Johansen updated: Friday August 05 2016 13:20

{"wide-big":{"output":{"width":572,"height":204},"crop":{"x":0,"width":1024,"y":0,"height":367}}}

Here in R&D, we're using Status Hero for our daily status reports. Since I'm using Emacs and Org mode for my notes and TODO items, I wrote the following script to export these into a format suitable for my Status Hero report.

All my tasks, notes, Google Calendar entries and so on are stored in .org files on my computer. For this Status Hero report, however, I only want to include the items from my work.org as this is where I create the task items.

This is an example output from the script:

$ org-agenda.sh 
Week-agenda (W31):
Monday      1 August 2016 W31
    ✔ VF-3324 follow up on questions from QA
    ✔ Create a new RC of ECE6
Tuesday     2 August 2016
    ✔ deploy waiter on example.com        #dpres
    ✔ fix upload-maven.sh for engine-<version>.zip #ece
    ✔ Follow up with ExAmple regarding CS/preview panel #example
Wednesday   3 August 2016
    ✔ Follow up with QA on VF-44638 Split "actual changes" from "incidental changes" in changelog #ece #qa
    ✔ Inform about ECE 6.0.0-4 build              #ece
Thursday    4 August 2016
    STARTED Setup example.com prod site      #dpres
    ✔ Contact @ziku to get `{test.,}example.com` into the DNS #dpres
    ✔ Help out with git merge issues section-feed and menu-editor #build
..

The script utilises the batch features of Emacs and Org mode:

#! /usr/bin/env bash

## Command to create an agenda view from org mode suitable for emails
## and Status Hero.

##          author: torstein@escenic.com
set -o errexit
set -o nounset
set -o pipefail
shopt -s nullglob

main() {
  format=${1-""}
  org_agenda=
  org_agenda=$(
    emacs -batch -l ~/.emacs.d/tkj-org.el \
          -eval '(org-batch-agenda "a"
          org-agenda-span (quote week)
          org-agenda-include-diary t
          org-agenda-files (quote ("~/doc/work.org")))' \
            2>/dev/null)

  result=
  result=$(
    echo "${org_agenda}" |
      sed -r -e 's#:([^:^ ]+)#\#\1 #g' -e 's# :$##' |
      sed -r 's#work:.* Sched. [0-9]+x:.*STARTED#  CONTINUE#' |
      sed -r 's#work:.* Sched.*:##' |
      sed -r 's#TODO ##' |
      sed -r 's#DONE # #')

  if [[ ${format} == "markdown" ]]; then
    echo "${result}" | \
      sed -r 's#^[ ]+#- #'
  else
    echo "${result}"
  fi
}

main "$@"