0.3.1 • Published 4 years ago

reportwarrior v0.3.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

ReportWarrior

Tooling to create reports from TaskWarrior using Mozilla Nunjucks. This tool is ofcourse not limited to HTML. You can generate Markdown reports as well.

Installation

$ npm install -g reportwarrior

Usage

First usage will install configuration in ~/.reportwarrior.

$ task export | reportwarrior -f basic
$ task export | reportwarrior --flow clientAbc

Example output:

<h2>
   <span style="font-weight: bold;background-color: orange;">&nbsp;Pending&nbsp;</span>
   <span>&nbsp;<i>HASS: program Volume control, from Audiolab M-DAC to TV</i></span>
</h2>
<table>
   <tr>
      <th>Priority</th>
      <td>Low</td>
   </tr>
</table>
<small>Task ref bfafac85-84d5-47ab-9d11-0db61c6fd57c</small>
<hr/>
<h2>
   <span style="font-weight: bold;background-color: orange;">&nbsp;Pending&nbsp;</span>
   <span>&nbsp;<i>Buy bookshelves</i></span>
</h2>
<table>
   <tr>
      <th>Priority</th>
      <td>Medium</td>
   </tr>
</table>
<small>Task ref 55713ae1-9d75-48e9-ae28-800da70a4447</small>
<hr/>
<h2>
   <span style="font-weight: bold;background-color: orange;">&nbsp;Pending&nbsp;</span>
   <span>&nbsp;<i>HASS: Add TV to HomeAssistant</i></span>
</h2>
<table>
   <tr>
      <th>Priority</th>
      <td>Low</td>
   </tr>
</table>
<small>Task ref 4a04082b-af4c-46e3-a9b6-c981243cd654</small>
<hr/>

Configuration

In the configuration, as seen as below, there are options to create your own titles, recipients and use specific templates per flow. In the configuration, you could even define momentjs-filters for Mozilla Nunjucks or use momentjs in your configuration. To do that, first run npm init && npm install --save moment in your ~/.reportwarrior-directory.

const os = require('os');
const path = require('path');

module.exports = {
    registerFilters: (njk) => {
        njk.addFilter('priority', p => ({ 'H': 'High', 'M': 'Medium', 'L': 'Low' })[p])
    },
    paths: { templates: path.resolve(os.homedir(), '.reportwarrior/templates') },
    flows: {
        basic: { template: "basic.html.njk" },
        email: { template: "email.html.njk" },
    }
}

Templates

Templates are using Mozilla Nunjucks. You can register new Filters in the configuration file.

Use with email

IMAP

Taskwarrior can easily be used in combination with IMAP. I personally use this to create a Draft on the remote server, to be able to check it and send it later on. You can even make a cronjob out of it.

$ TMP=$(mktemp); task export | reportwarrior -f email > $TMP && curl --url "imaps://imap.gmail.com:993/%5BGmail%5D%2FDrafts" --user "user@gmail.com:password" -T $TMP && rm $TMP

In this example, please replace the URL, TaskWarrior filters, username and password appropriately. You can replace the encoded suffix [Gmail]Drafts with any you want. For a IMAP representation of labels:

$ curl --url "imaps://imap.gmail.com:993/" --user "user@gmail.com:password"

In Gmail, you can easily create new labels. Those are usable by IMAP clients such as cURL.

SMTP

Due to somewhat more complexity (we need to insert the sender and receiver and still maintain the template as is), we use a somewhat different oneliner for sending email using SMTP:

$ export TMP=$(mktemp); task export | reportwarrior -f email > $TMP && curl -kv --url "smtps://smtp.gmail.com:465/" --user "user@gmail.com:password" --mail-from "$(grep -P "^From:.*<(.*)>" $TMP | grep -o "<.*>" | sed -e 's/^.//' -e 's/.$//')" --mail-rcpt "$(grep -P "^To:.*<(.*)>" $TMP | grep -o "<.*>" | sed -e 's/^.//' -e 's/.$//')" -T $TMP

The chained grep and sed are responsible for optaining the From and To header from the generated output. I hope I will find an easier way to do this, but this works for now.

--mail-from "$(grep -P "^From:.*<(.*)>" $TMP | grep -o "<.*>" | sed -e 's/^.//' -e 's/.$//')"
0.3.1

4 years ago

0.3.0

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago