#!/usr/bin/env node

var app = require('commander')
var moment = require('moment')
var getLists = require('./lib/get-lists')
var printList = require('./lib/print-list')
var auth = require('./lib/auth')

app
  .description('View tasks due today')
  .parse(process.argv)

function main () {
  getLists(function (err, data) {
    if (err) process.exit(1)

    var today = moment().format('YYYY-MM-DD')

    data.forEach(function (list) {
      list.tasks = list.tasks.filter(function (item) {
        if (!item.due_date) return false
        return item.due_date === today
      })

      printList(list)
    })
  })
}

auth(main)

#!/usr/bin/env node

var app = require('commander')
var moment = require('moment')
var getLists = require('./lib/get-lists')
var printList = require('./lib/print-list')
var auth = require('./lib/auth')

app
  .description('View tasks due today')
  .parse(process.argv)

function main () {
  getLists(function (err, data) {
    if (err) process.exit(1)

    var today = new Date()

    data.forEach(function (list) {
      list.tasks = list.tasks.filter(function (item) {
        if (!item.due_date) return false
        var due = new Date(item.due_date)
        return due.getTime() <= today.getTime()
      })

      printList(list)
    })
  })
}

auth(main)

Include overdue items in the "today" smart list
Include overdue items in the "today" smart list

To keep parity between the CLI and the native GUI (at least for OSX), the Today smart list should include items that are Overdue as well as those explicitly due on that given day.