Skip to content

Instantly share code, notes, and snippets.

@projectivemotion
Last active September 1, 2016 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save projectivemotion/9614c250b6c2902e35e677f015ac500a to your computer and use it in GitHub Desktop.
Save projectivemotion/9614c250b6c2902e35e677f015ac500a to your computer and use it in GitHub Desktop.
Example Script to obtain taskwarrior information using node js
/**
* Amado Martinez <amadomartinez.mx>
*
* Example Typescript / Javascript to retrieve taskwarrior data
*/
var execSync = require("child_process").execSync;
var getIds = (filter) => {
let ids = execSync("task " + filter + " _id").toString().split("\n");
ids.pop(); // remove empty line
return ids;
};
var getProperty = (prop, id) => {
return execSync("task _get " + id + "." + prop).toString().trim();
};
//console.log(getIds('+ACTIVE'));
var active = getIds('+ACTIVE');
var descriptions = active.map((id) => {
return getProperty("description", id);
});
console.log(descriptions);
/**
* Amado Martinez <amadomartinez.mx>
*
* Example Typescript / Javascript to retrieve taskwarrior data
*/
var execSync = require("child_process").execSync;
var getIds = (filter) => {
let ids = execSync("task " + filter + " _id").toString().split("\n");
ids.pop(); // remove empty line
return ids;
} ;
var getProperty = (prop, id) => {
return execSync("task _get " + id + "."+prop).toString().trim();
};
//console.log(getIds('+ACTIVE'));
var active=getIds('+ACTIVE');
var descriptions = active.map((id) => {
return getProperty("description", id);
});
console.log(descriptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment