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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ of task create "Name" [options]
--note <text> # Add note

of task update <name|id> [options]
--complete # Mark completed
--complete / --incomplete # Mark completed/incomplete
--drop / --undrop # Mark dropped/restore to active
--flag / --unflag # Toggle flag
--name <new-name> # Rename
--project/--tag/--due/--defer # Same as create
Expand Down
4 changes: 4 additions & 0 deletions src/commands/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export function createTaskCommand(): Command {
.option('-F, --unflag', 'Unflag the task')
.option('-c, --complete', 'Mark as completed')
.option('-C, --incomplete', 'Mark as incomplete')
.option('--drop', 'Mark as dropped')
.option('--undrop', 'Restore a dropped task to active')
.option('-e, --estimate <minutes>', 'Estimated time in minutes', parseInt)
.action(
withErrorHandling(async (idOrName, options) => {
Expand All @@ -90,6 +92,8 @@ export function createTaskCommand(): Command {
...(options.unflag && { flagged: false }),
...(options.complete && { completed: true }),
...(options.incomplete && { completed: false }),
...(options.drop && { dropped: true }),
...(options.undrop && { dropped: false }),
...(options.estimate !== undefined && { estimatedMinutes: options.estimate }),
};
const task = await of.updateTask(idOrName, updates);
Expand Down
12 changes: 11 additions & 1 deletion src/lib/omnifocus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class OmniFocus {
name: task.name,
note: task.note || null,
completed: task.completed,
dropped: task.dropped,
dropped: task.dropDate !== null,
effectivelyActive: task.effectiveActive,
flagged: task.flagged,
project: containingProject ? containingProject.name : null,
Expand Down Expand Up @@ -354,6 +354,16 @@ export class OmniFocus {
if (options.completed !== undefined) {
updates.push(options.completed ? 'task.markComplete();' : 'task.markIncomplete();');
}
if (options.dropped !== undefined) {
updates.push(
options.dropped
? 'task.drop(false, null);'
// Guard against reactivating a completed task: `active` isn't
// specific to "dropped", so undrop is a no-op on a task that's
// completed rather than dropped.
: 'if (!task.completed) { task.active = true; }'
);
}
if (options.estimatedMinutes !== undefined) {
updates.push(`task.estimatedMinutes = ${options.estimatedMinutes};`);
}
Expand Down
1 change: 1 addition & 0 deletions src/mcp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ server.tool(
flagged: z.boolean().optional().describe('Flag/unflag the task'),
estimatedMinutes: z.number().optional().describe('New estimated duration'),
completed: z.boolean().optional().describe('Mark complete/incomplete'),
dropped: z.boolean().optional().describe('Mark dropped/undropped'),
},
async ({ idOrName, ...options }) => jsonResponse(await of.updateTask(idOrName, options))
);
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface UpdateTaskOptions {
flagged?: boolean;
estimatedMinutes?: number;
completed?: boolean;
dropped?: boolean;
}

export interface CreateProjectOptions {
Expand Down