Skip to content

DCsunset/taskwarrior-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

taskwarrior-lib

npm version license

A Node.js library for interacting with taskwarrior

Installation

npm install taskwarrior-lib

Requirements

  • Taskwarrior v2.4.5 or above (which supports import command)

Usage

The following examples are using ES modules, and CommonJS modules are also supported.

To import the library:

import { TaskwarriorLib } from 'taskwarrior-lib';
const taskwarrior = new TaskwarriorLib();

Or you can specify the taskwarrior config path and data path:

const taskwarrior = new TaskwarriorLib(
	'~/.taskrc',
	'~/.task'
);

To add tasks:

let msg = taskwarrior.update([
	{
		description: 'test 1',
		priority: 'L'
	},
	{
		description: 'test 2',
		priority: 'M'
	}
]);
console.log(msg);

To load tasks:

const tasks = taskwarrior.load('status:pending');
console.log(tasks);

To modify tasks:

const task = tasks[tasks.length - 1];
task.due = 'now+1d';
task.priority = 'H';
let msg = taskwarrior.update([task]);
console.log(msg);

To delete tasks:

taskwarrior.del(tasks.slice(tasks.length - 1));

License

MIT License

About

A Node.js library for interacting with taskwarrior

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published