-
Notifications
You must be signed in to change notification settings - Fork 0
/
todoist.js
executable file
·30 lines (25 loc) · 915 Bytes
/
todoist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env node
// include it
require('dotenv').config({ path: __dirname + '/.env' }); // https://www.npmjs.com/package/dotenv
const Todoist = require('todoist').v8 // https://www.npmjs.com/package/todoist
const chalk = require("chalk"); // https://www.npmjs.com/package/chalk
const {
sanitize
} = require('sanitize.js'); // https://www.npmjs.com/package/sanitize.js
//@TODO --help page
// load it
const todoist = Todoist(process.env.TODOIST_API)
// @TODO check for failure or missing API key
// get it
var todoTask = sanitize(process.argv.slice(2).join(' '));
// @TODO sanitization too strong, strips out slashes from links
// @TODO check for empty string
// @TODO add args for placing directly in projects/tags, etc.
// fire it
;(async () => {
const newItem = await todoist.items.add({
content: todoTask
})
// @TODO check for failures
console.log(chalk.green.bold('Added Todo: ' + todoTask));
})()