<commit_before>var SDK = require('wunderlist')
var dirty = require('dirty')
var db = dirty(__dirname + '/../cache.db')
var async = require('async')
var add = exports

var conf = {}
require('rc')('wunderlist-cli', conf)

var api = new SDK({
  'accessToken': conf.access_token,
  'clientID': conf.client_id
})

add.single = function (task, cb) {
  if (!task.title.trim()) {
    return cb()
  }
  task.list_id = db.get('inbox_id')
  if (task.list_id) {
    var req = api.http.tasks.create(task)
    req.then(function (res) {
      console.log('Created task ' + res.id)
      cb(res)
    })
  } else {
    var req = api.http.lists.all()
    req.then(function (res) {
      task.list_id = res[0].id
      db.set('inbox_id', task.list_id)

      var req = api.http.tasks.create(task)
      req.then(function (res) {
        console.log('Created task ' + res.id)
        cb(res)
      })
    })
  }
}

add.multiple = function (tasks, cb) {
  async.eachLimit(tasks, 4, function (task, finished) {
    add.single(task, function () {
      finished()
    })
  }, function (err) {
    cb(err)
  })<commit_msg>nicer logging<commit_after>var cli = require('cli')
var SDK = require('wunderlist')
var dirty = require('dirty')
var db = dirty(__dirname + '/../cache.db')
var async = require('async')
var add = exports

var conf = {}
require('rc')('wunderlist-cli', conf)

var api = new SDK({
  'accessToken': conf.access_token,
  'clientID': conf.client_id
})

add.single = function (task, cb) {
  if (!task.title.trim()) {
    return cb()
  }
  task.list_id = db.get('inbox_id')
  if (task.list_id) {
    var req = api.http.tasks.create(task)
    req.then(function (res) {
      cli.ok('Created task ' + res.id)
      cb(res)
    })
  } else {
    var req = api.http.lists.all()
    req.then(function (res) {
      task.list_id = res[0].id
      db.set('inbox_id', task.list_id)

      var req = api.http.tasks.create(task)
      req.then(function (res) {
        cli.ok('Created task ' + res.id)
        cb(res)
      })
    })
  }
}

add.multiple = function (tasks, cb) {
  async.eachLimit(tasks, 4, function (task, finished) {
    add.single(task, function () {
      finished()
    })
  }, function (err) {
    cb(err)
  })
{'fraction_non_alphanumeric': 0.17503392130257803, 'fraction_numerical': 0.0018091361374943465, 'mean_word_length': 2.7364864864864864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1404501', 'n_tokens_mistral': 814, 'n_tokens_neox': 803, 'n_words': 170}