Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ program
.description('A command-line interface for OmniFocus on macOS')
.version(__VERSION__)
.option('-c, --compact', 'Minified JSON output (single line)')
.option('-j, --json', 'Force JSON output (default when piped)')
.hook('preAction', (thisCommand) => {
const options = thisCommand.opts();
setOutputOptions({
compact: options.compact,
json: options.json,
});
});

Expand Down
27 changes: 22 additions & 5 deletions src/commands/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,31 @@ export function createTaskCommand(): Command {
);

command
.command('delete <idOrName>')
.command('complete <idsOrNames...>')
.alias('done')
.description('Mark one or more tasks as completed')
.action(
withErrorHandling(async (idsOrNames: string[]) => {
const of = new OmniFocus();
const tasks = await of.completeTasks(idsOrNames);
outputJson(tasks);
})
);

command
.command('delete <idsOrNames...>')
.alias('rm')
.description('Delete a task')
.description('Delete one or more tasks')
.action(
withErrorHandling(async (idOrName) => {
withErrorHandling(async (idsOrNames: string[]) => {
const of = new OmniFocus();
await of.deleteTask(idOrName);
outputJson({ message: 'Task deleted successfully' });
if (idsOrNames.length === 1) {
await of.deleteTask(idsOrNames[0]);
outputJson({ message: 'Task deleted successfully' });
} else {
const count = await of.deleteTasks(idsOrNames);
outputJson({ message: `${count} tasks deleted successfully` });
}
})
);

Expand Down
Loading