@stephendolan/omnifocus-cli 2.0.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -431
- package/dist/{index.js → cli.js} +288 -277
- package/dist/cli.js.map +1 -0
- package/package.json +6 -8
- package/dist/index.js.map +0 -1
package/dist/{index.js → cli.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
// src/
|
|
3
|
+
// src/cli.ts
|
|
4
4
|
import { Command as Command8 } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/lib/output.ts
|
|
@@ -17,9 +17,45 @@ function outputJson(data, options = {}) {
|
|
|
17
17
|
// src/commands/task.ts
|
|
18
18
|
import { Command } from "commander";
|
|
19
19
|
|
|
20
|
+
// src/lib/errors.ts
|
|
21
|
+
var OmniFocusCliError = class extends Error {
|
|
22
|
+
constructor(message, statusCode = 500) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.statusCode = statusCode;
|
|
25
|
+
this.name = "OmniFocusCliError";
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function handleError(error) {
|
|
29
|
+
let name = "unknown_error";
|
|
30
|
+
let detail = "An unknown error occurred";
|
|
31
|
+
let statusCode = 500;
|
|
32
|
+
if (error instanceof OmniFocusCliError) {
|
|
33
|
+
name = "cli_error";
|
|
34
|
+
detail = error.message;
|
|
35
|
+
statusCode = error.statusCode;
|
|
36
|
+
} else if (error instanceof Error) {
|
|
37
|
+
name = "omnifocus_error";
|
|
38
|
+
detail = error.message;
|
|
39
|
+
if (detail.includes("not found")) {
|
|
40
|
+
statusCode = 404;
|
|
41
|
+
} else if (detail.includes("Multiple")) {
|
|
42
|
+
statusCode = 400;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
outputJson({ error: { name, detail, statusCode } });
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
20
49
|
// src/lib/command-utils.ts
|
|
21
|
-
|
|
22
|
-
|
|
50
|
+
function withErrorHandling(fn) {
|
|
51
|
+
return async (...args) => {
|
|
52
|
+
try {
|
|
53
|
+
await fn(...args);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
handleError(error);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
23
59
|
|
|
24
60
|
// src/lib/omnifocus.ts
|
|
25
61
|
import { execFile } from "child_process";
|
|
@@ -333,7 +369,7 @@ var OmniFocus = class {
|
|
|
333
369
|
updates.push(`task.flagged = ${options.flagged};`);
|
|
334
370
|
}
|
|
335
371
|
if (options.completed !== void 0) {
|
|
336
|
-
updates.push(
|
|
372
|
+
updates.push(options.completed ? "task.markComplete();" : "task.markIncomplete();");
|
|
337
373
|
}
|
|
338
374
|
if (options.estimatedMinutes !== void 0) {
|
|
339
375
|
updates.push(`task.estimatedMinutes = ${options.estimatedMinutes};`);
|
|
@@ -945,109 +981,94 @@ var OmniFocus = class {
|
|
|
945
981
|
}
|
|
946
982
|
};
|
|
947
983
|
|
|
948
|
-
// src/lib/
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
onSuccess?.(result);
|
|
955
|
-
return result;
|
|
956
|
-
} catch (error) {
|
|
957
|
-
spinner.fail(failureMessage || "Command failed");
|
|
958
|
-
console.error(chalk.red(error.message));
|
|
959
|
-
throw error;
|
|
984
|
+
// src/lib/dates.ts
|
|
985
|
+
import dayjs from "dayjs";
|
|
986
|
+
function parseDateTime(input) {
|
|
987
|
+
const d = dayjs(input);
|
|
988
|
+
if (!d.isValid()) {
|
|
989
|
+
throw new OmniFocusCliError(`Invalid date: ${input}`, 400);
|
|
960
990
|
}
|
|
961
|
-
|
|
962
|
-
async function executeOmniFocusCommand(loadingMessage, action, onSuccess, failureMessage) {
|
|
963
|
-
const of = new OmniFocus();
|
|
964
|
-
return executeCommand(loadingMessage, () => action(of), onSuccess, failureMessage);
|
|
991
|
+
return d.toISOString();
|
|
965
992
|
}
|
|
966
993
|
|
|
967
994
|
// src/commands/task.ts
|
|
968
995
|
function createTaskCommand() {
|
|
969
996
|
const command = new Command("task");
|
|
970
997
|
command.description("Manage OmniFocus tasks");
|
|
971
|
-
command.command("list").alias("ls").description("List tasks").option("-f, --flagged", "Show only flagged tasks").option("-p, --project <name>", "Filter by project").option("-t, --tag <name>", "Filter by tag").option("-c, --completed", "Include completed tasks").action(
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
)
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
await executeOmniFocusCommand(
|
|
989
|
-
"Creating task...",
|
|
990
|
-
(of) => of.createTask({
|
|
998
|
+
command.command("list").alias("ls").description("List tasks").option("-f, --flagged", "Show only flagged tasks").option("-p, --project <name>", "Filter by project").option("-t, --tag <name>", "Filter by tag").option("-c, --completed", "Include completed tasks").action(
|
|
999
|
+
withErrorHandling(async (options) => {
|
|
1000
|
+
const of = new OmniFocus();
|
|
1001
|
+
const filters = {
|
|
1002
|
+
includeCompleted: options.completed,
|
|
1003
|
+
...options.flagged && { flagged: true },
|
|
1004
|
+
...options.project && { project: options.project },
|
|
1005
|
+
...options.tag && { tag: options.tag }
|
|
1006
|
+
};
|
|
1007
|
+
const tasks = await of.listTasks(filters);
|
|
1008
|
+
outputJson(tasks);
|
|
1009
|
+
})
|
|
1010
|
+
);
|
|
1011
|
+
command.command("create <name>").description("Create a new task").option("-p, --project <name>", "Assign to project").option("--note <text>", "Add note").option("-t, --tag <tags...>", "Add tags").option("-d, --due <date>", "Set due date").option("-D, --defer <date>", "Set defer date").option("-f, --flagged", "Flag the task").option("-e, --estimate <minutes>", "Estimated time in minutes", parseInt).action(
|
|
1012
|
+
withErrorHandling(async (name, options) => {
|
|
1013
|
+
const of = new OmniFocus();
|
|
1014
|
+
const task = await of.createTask({
|
|
991
1015
|
name,
|
|
992
1016
|
note: options.note,
|
|
993
1017
|
project: options.project,
|
|
994
1018
|
tags: options.tag,
|
|
995
|
-
due: options.due,
|
|
996
|
-
defer: options.defer,
|
|
1019
|
+
due: options.due ? parseDateTime(options.due) : void 0,
|
|
1020
|
+
defer: options.defer ? parseDateTime(options.defer) : void 0,
|
|
997
1021
|
flagged: options.flagged,
|
|
998
1022
|
estimatedMinutes: options.estimate
|
|
999
|
-
})
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
)
|
|
1026
|
-
|
|
1027
|
-
command.command("delete <idOrName>").alias("rm").description("Delete a task").action(
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
(
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
"Failed to analyze tasks"
|
|
1049
|
-
);
|
|
1050
|
-
});
|
|
1023
|
+
});
|
|
1024
|
+
outputJson(task);
|
|
1025
|
+
})
|
|
1026
|
+
);
|
|
1027
|
+
command.command("update <idOrName>").description("Update an existing task").option("-n, --name <name>", "New name").option("--note <text>", "New note").option("-p, --project <name>", "Move to project").option("-t, --tag <tags...>", "Replace tags").option("-d, --due <date>", "Set due date").option("-D, --defer <date>", "Set defer date").option("-f, --flag", "Flag the task").option("-F, --unflag", "Unflag the task").option("-c, --complete", "Mark as completed").option("-C, --incomplete", "Mark as incomplete").option("-e, --estimate <minutes>", "Estimated time in minutes", parseInt).action(
|
|
1028
|
+
withErrorHandling(async (idOrName, options) => {
|
|
1029
|
+
const of = new OmniFocus();
|
|
1030
|
+
const updates = {
|
|
1031
|
+
...options.name && { name: options.name },
|
|
1032
|
+
...options.note !== void 0 && { note: options.note },
|
|
1033
|
+
...options.project && { project: options.project },
|
|
1034
|
+
...options.tag && { tags: options.tag },
|
|
1035
|
+
...options.due !== void 0 && {
|
|
1036
|
+
due: options.due ? parseDateTime(options.due) : null
|
|
1037
|
+
},
|
|
1038
|
+
...options.defer !== void 0 && {
|
|
1039
|
+
defer: options.defer ? parseDateTime(options.defer) : null
|
|
1040
|
+
},
|
|
1041
|
+
...options.flag && { flagged: true },
|
|
1042
|
+
...options.unflag && { flagged: false },
|
|
1043
|
+
...options.complete && { completed: true },
|
|
1044
|
+
...options.incomplete && { completed: false },
|
|
1045
|
+
...options.estimate !== void 0 && { estimatedMinutes: options.estimate }
|
|
1046
|
+
};
|
|
1047
|
+
const task = await of.updateTask(idOrName, updates);
|
|
1048
|
+
outputJson(task);
|
|
1049
|
+
})
|
|
1050
|
+
);
|
|
1051
|
+
command.command("delete <idOrName>").alias("rm").description("Delete a task").action(
|
|
1052
|
+
withErrorHandling(async (idOrName) => {
|
|
1053
|
+
const of = new OmniFocus();
|
|
1054
|
+
await of.deleteTask(idOrName);
|
|
1055
|
+
outputJson({ message: "Task deleted successfully" });
|
|
1056
|
+
})
|
|
1057
|
+
);
|
|
1058
|
+
command.command("view <idOrName>").description("View task details").action(
|
|
1059
|
+
withErrorHandling(async (idOrName) => {
|
|
1060
|
+
const of = new OmniFocus();
|
|
1061
|
+
const task = await of.getTask(idOrName);
|
|
1062
|
+
outputJson(task);
|
|
1063
|
+
})
|
|
1064
|
+
);
|
|
1065
|
+
command.command("stats").description("Show task statistics").action(
|
|
1066
|
+
withErrorHandling(async () => {
|
|
1067
|
+
const of = new OmniFocus();
|
|
1068
|
+
const stats = await of.getTaskStats();
|
|
1069
|
+
outputJson(stats);
|
|
1070
|
+
})
|
|
1071
|
+
);
|
|
1051
1072
|
return command;
|
|
1052
1073
|
}
|
|
1053
1074
|
|
|
@@ -1056,79 +1077,69 @@ import { Command as Command2 } from "commander";
|
|
|
1056
1077
|
function createProjectCommand() {
|
|
1057
1078
|
const command = new Command2("project");
|
|
1058
1079
|
command.description("Manage OmniFocus projects");
|
|
1059
|
-
command.command("list").alias("ls").description("List projects").option("-f, --folder <name>", "Filter by folder").option("-s, --status <status>", "Filter by status (active, on hold, dropped)").option("-d, --dropped", "Include dropped projects").action(
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
)
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
await executeOmniFocusCommand(
|
|
1076
|
-
"Creating project...",
|
|
1077
|
-
(of) => of.createProject({
|
|
1080
|
+
command.command("list").alias("ls").description("List projects").option("-f, --folder <name>", "Filter by folder").option("-s, --status <status>", "Filter by status (active, on hold, dropped)").option("-d, --dropped", "Include dropped projects").action(
|
|
1081
|
+
withErrorHandling(async (options) => {
|
|
1082
|
+
const of = new OmniFocus();
|
|
1083
|
+
const filters = {
|
|
1084
|
+
includeDropped: options.dropped,
|
|
1085
|
+
...options.folder && { folder: options.folder },
|
|
1086
|
+
...options.status && { status: options.status }
|
|
1087
|
+
};
|
|
1088
|
+
const projects = await of.listProjects(filters);
|
|
1089
|
+
outputJson(projects);
|
|
1090
|
+
})
|
|
1091
|
+
);
|
|
1092
|
+
command.command("create <name>").description("Create a new project").option("-f, --folder <name>", "Assign to folder").option("--note <text>", "Add note").option("-t, --tag <tags...>", "Add tags").option("-s, --sequential", "Make it a sequential project").option("--status <status>", "Set status (active, on hold, dropped)").action(
|
|
1093
|
+
withErrorHandling(async (name, options) => {
|
|
1094
|
+
const of = new OmniFocus();
|
|
1095
|
+
const project = await of.createProject({
|
|
1078
1096
|
name,
|
|
1079
1097
|
note: options.note,
|
|
1080
1098
|
folder: options.folder,
|
|
1081
1099
|
tags: options.tag,
|
|
1082
1100
|
sequential: options.sequential,
|
|
1083
1101
|
status: options.status
|
|
1084
|
-
})
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
await executeOmniFocusCommand(
|
|
1126
|
-
"Analyzing projects...",
|
|
1127
|
-
(of) => of.getProjectStats(),
|
|
1128
|
-
(stats) => outputJson(stats),
|
|
1129
|
-
"Failed to analyze projects"
|
|
1130
|
-
);
|
|
1131
|
-
});
|
|
1102
|
+
});
|
|
1103
|
+
outputJson(project);
|
|
1104
|
+
})
|
|
1105
|
+
);
|
|
1106
|
+
command.command("update <idOrName>").description("Update an existing project").option("-n, --name <name>", "Rename project").option("--note <text>", "New note").option("-f, --folder <name>", "Move to folder").option("-t, --tag <tags...>", "Replace tags").option("-s, --sequential", "Make it sequential").option("-p, --parallel", "Make it parallel").option("--status <status>", "Set status (active, on hold, dropped)").action(
|
|
1107
|
+
withErrorHandling(async (idOrName, options) => {
|
|
1108
|
+
const of = new OmniFocus();
|
|
1109
|
+
const updates = {
|
|
1110
|
+
...options.name && { name: options.name },
|
|
1111
|
+
...options.note !== void 0 && { note: options.note },
|
|
1112
|
+
...options.folder && { folder: options.folder },
|
|
1113
|
+
...options.tag && { tags: options.tag },
|
|
1114
|
+
...options.sequential && { sequential: true },
|
|
1115
|
+
...options.parallel && { sequential: false },
|
|
1116
|
+
...options.status && { status: options.status }
|
|
1117
|
+
};
|
|
1118
|
+
const project = await of.updateProject(idOrName, updates);
|
|
1119
|
+
outputJson(project);
|
|
1120
|
+
})
|
|
1121
|
+
);
|
|
1122
|
+
command.command("delete <idOrName>").alias("rm").description("Delete a project").action(
|
|
1123
|
+
withErrorHandling(async (idOrName) => {
|
|
1124
|
+
const of = new OmniFocus();
|
|
1125
|
+
await of.deleteProject(idOrName);
|
|
1126
|
+
outputJson({ message: "Project deleted successfully" });
|
|
1127
|
+
})
|
|
1128
|
+
);
|
|
1129
|
+
command.command("view <idOrName>").description("View project details").action(
|
|
1130
|
+
withErrorHandling(async (idOrName) => {
|
|
1131
|
+
const of = new OmniFocus();
|
|
1132
|
+
const project = await of.getProject(idOrName);
|
|
1133
|
+
outputJson(project);
|
|
1134
|
+
})
|
|
1135
|
+
);
|
|
1136
|
+
command.command("stats").description("Show project statistics").action(
|
|
1137
|
+
withErrorHandling(async () => {
|
|
1138
|
+
const of = new OmniFocus();
|
|
1139
|
+
const stats = await of.getProjectStats();
|
|
1140
|
+
outputJson(stats);
|
|
1141
|
+
})
|
|
1142
|
+
);
|
|
1132
1143
|
return command;
|
|
1133
1144
|
}
|
|
1134
1145
|
|
|
@@ -1137,22 +1148,35 @@ import { Command as Command3 } from "commander";
|
|
|
1137
1148
|
function createInboxCommand() {
|
|
1138
1149
|
const command = new Command3("inbox");
|
|
1139
1150
|
command.description("Manage OmniFocus inbox");
|
|
1140
|
-
command.command("list").alias("ls").description("List inbox tasks").action(
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
(
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1151
|
+
command.command("list").alias("ls").description("List inbox tasks").action(
|
|
1152
|
+
withErrorHandling(async () => {
|
|
1153
|
+
const of = new OmniFocus();
|
|
1154
|
+
const tasks = await of.listInboxTasks();
|
|
1155
|
+
outputJson(tasks);
|
|
1156
|
+
})
|
|
1157
|
+
);
|
|
1158
|
+
command.command("count").description("Get inbox count").action(
|
|
1159
|
+
withErrorHandling(async () => {
|
|
1160
|
+
const of = new OmniFocus();
|
|
1161
|
+
const count = await of.getInboxCount();
|
|
1162
|
+
outputJson({ count });
|
|
1163
|
+
})
|
|
1164
|
+
);
|
|
1165
|
+
command.command("add <name>").description("Add a task to inbox").option("--note <text>", "Add note").option("-t, --tag <tags...>", "Add tags").option("-d, --due <date>", "Set due date").option("-D, --defer <date>", "Set defer date").option("-f, --flagged", "Flag the task").option("-e, --estimate <minutes>", "Estimated time in minutes", parseInt).action(
|
|
1166
|
+
withErrorHandling(async (name, options) => {
|
|
1167
|
+
const of = new OmniFocus();
|
|
1168
|
+
const task = await of.createTask({
|
|
1169
|
+
name,
|
|
1170
|
+
note: options.note,
|
|
1171
|
+
tags: options.tag,
|
|
1172
|
+
due: options.due ? parseDateTime(options.due) : void 0,
|
|
1173
|
+
defer: options.defer ? parseDateTime(options.defer) : void 0,
|
|
1174
|
+
flagged: options.flagged,
|
|
1175
|
+
estimatedMinutes: options.estimate
|
|
1176
|
+
});
|
|
1177
|
+
outputJson(task);
|
|
1178
|
+
})
|
|
1179
|
+
);
|
|
1156
1180
|
return command;
|
|
1157
1181
|
}
|
|
1158
1182
|
|
|
@@ -1162,14 +1186,13 @@ function createSearchCommand() {
|
|
|
1162
1186
|
const command = new Command4("search");
|
|
1163
1187
|
command.description("Search tasks by name or note");
|
|
1164
1188
|
command.argument("<query>", "Search query");
|
|
1165
|
-
command.action(
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
});
|
|
1189
|
+
command.action(
|
|
1190
|
+
withErrorHandling(async (query) => {
|
|
1191
|
+
const of = new OmniFocus();
|
|
1192
|
+
const tasks = await of.searchTasks(query);
|
|
1193
|
+
outputJson(tasks);
|
|
1194
|
+
})
|
|
1195
|
+
);
|
|
1173
1196
|
return command;
|
|
1174
1197
|
}
|
|
1175
1198
|
|
|
@@ -1178,22 +1201,20 @@ import { Command as Command5 } from "commander";
|
|
|
1178
1201
|
function createPerspectiveCommand() {
|
|
1179
1202
|
const command = new Command5("perspective");
|
|
1180
1203
|
command.description("Manage OmniFocus perspectives");
|
|
1181
|
-
command.command("list").alias("ls").description("List all perspectives").action(
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
(
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
);
|
|
1196
|
-
});
|
|
1204
|
+
command.command("list").alias("ls").description("List all perspectives").action(
|
|
1205
|
+
withErrorHandling(async () => {
|
|
1206
|
+
const of = new OmniFocus();
|
|
1207
|
+
const perspectives = await of.listPerspectives();
|
|
1208
|
+
outputJson(perspectives);
|
|
1209
|
+
})
|
|
1210
|
+
);
|
|
1211
|
+
command.command("view <name>").description("View tasks in a perspective").action(
|
|
1212
|
+
withErrorHandling(async (name) => {
|
|
1213
|
+
const of = new OmniFocus();
|
|
1214
|
+
const tasks = await of.getPerspectiveTasks(name);
|
|
1215
|
+
outputJson(tasks);
|
|
1216
|
+
})
|
|
1217
|
+
);
|
|
1197
1218
|
return command;
|
|
1198
1219
|
}
|
|
1199
1220
|
|
|
@@ -1202,68 +1223,60 @@ import { Command as Command6 } from "commander";
|
|
|
1202
1223
|
function createTagCommand() {
|
|
1203
1224
|
const command = new Command6("tag");
|
|
1204
1225
|
command.description("Manage and analyze OmniFocus tags");
|
|
1205
|
-
command.command("list").alias("ls").description("List tags with usage information").option("-u, --unused-days <days>", "Show tags unused for N days", parseInt).option("-s, --sort <field>", "Sort by: name, usage, activity (default: name)", "name").option("-a, --active-only", "Only count active (incomplete) tasks").action(
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1226
|
+
command.command("list").alias("ls").description("List tags with usage information").option("-u, --unused-days <days>", "Show tags unused for N days", parseInt).option("-s, --sort <field>", "Sort by: name, usage, activity (default: name)", "name").option("-a, --active-only", "Only count active (incomplete) tasks").action(
|
|
1227
|
+
withErrorHandling(async (options) => {
|
|
1228
|
+
const of = new OmniFocus();
|
|
1229
|
+
const tags = await of.listTags({
|
|
1209
1230
|
unusedDays: options.unusedDays,
|
|
1210
1231
|
sortBy: options.sort,
|
|
1211
1232
|
activeOnly: options.activeOnly
|
|
1212
|
-
})
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
(of) => of.createTag({
|
|
1233
|
+
});
|
|
1234
|
+
outputJson(tags);
|
|
1235
|
+
})
|
|
1236
|
+
);
|
|
1237
|
+
command.command("create <name>").description("Create a new tag").option("-p, --parent <name>", "Create as child of parent tag").option("-s, --status <status>", "Set status (active, on hold, dropped)").action(
|
|
1238
|
+
withErrorHandling(async (name, options) => {
|
|
1239
|
+
const of = new OmniFocus();
|
|
1240
|
+
const tag = await of.createTag({
|
|
1221
1241
|
name,
|
|
1222
1242
|
parent: options.parent,
|
|
1223
1243
|
status: options.status
|
|
1224
|
-
})
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
(
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
await executeOmniFocusCommand(
|
|
1261
|
-
"Analyzing tags...",
|
|
1262
|
-
(of) => of.getTagStats(),
|
|
1263
|
-
(stats) => outputJson(stats),
|
|
1264
|
-
"Failed to analyze tags"
|
|
1265
|
-
);
|
|
1266
|
-
});
|
|
1244
|
+
});
|
|
1245
|
+
outputJson(tag);
|
|
1246
|
+
})
|
|
1247
|
+
);
|
|
1248
|
+
command.command("view <idOrName>").description("View tag details").action(
|
|
1249
|
+
withErrorHandling(async (idOrName) => {
|
|
1250
|
+
const of = new OmniFocus();
|
|
1251
|
+
const tag = await of.getTag(idOrName);
|
|
1252
|
+
outputJson(tag);
|
|
1253
|
+
})
|
|
1254
|
+
);
|
|
1255
|
+
command.command("update <idOrName>").description("Update an existing tag").option("-n, --name <name>", "Rename tag").option("-s, --status <status>", "Set status (active, on hold, dropped)").action(
|
|
1256
|
+
withErrorHandling(async (idOrName, options) => {
|
|
1257
|
+
const of = new OmniFocus();
|
|
1258
|
+
const updates = {
|
|
1259
|
+
...options.name && { name: options.name },
|
|
1260
|
+
...options.status && { status: options.status }
|
|
1261
|
+
};
|
|
1262
|
+
const tag = await of.updateTag(idOrName, updates);
|
|
1263
|
+
outputJson(tag);
|
|
1264
|
+
})
|
|
1265
|
+
);
|
|
1266
|
+
command.command("delete <idOrName>").alias("rm").description("Delete a tag").action(
|
|
1267
|
+
withErrorHandling(async (idOrName) => {
|
|
1268
|
+
const of = new OmniFocus();
|
|
1269
|
+
await of.deleteTag(idOrName);
|
|
1270
|
+
outputJson({ message: "Tag deleted successfully" });
|
|
1271
|
+
})
|
|
1272
|
+
);
|
|
1273
|
+
command.command("stats").description("Show tag usage statistics").action(
|
|
1274
|
+
withErrorHandling(async () => {
|
|
1275
|
+
const of = new OmniFocus();
|
|
1276
|
+
const stats = await of.getTagStats();
|
|
1277
|
+
outputJson(stats);
|
|
1278
|
+
})
|
|
1279
|
+
);
|
|
1267
1280
|
return command;
|
|
1268
1281
|
}
|
|
1269
1282
|
|
|
@@ -1272,29 +1285,27 @@ import { Command as Command7 } from "commander";
|
|
|
1272
1285
|
function createFolderCommand() {
|
|
1273
1286
|
const command = new Command7("folder");
|
|
1274
1287
|
command.description("View OmniFocus folder hierarchy");
|
|
1275
|
-
command.command("list").alias("ls").description("List top-level folders with nested children").option("-d, --dropped", "Include dropped folders").action(
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
(
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
);
|
|
1291
|
-
});
|
|
1288
|
+
command.command("list").alias("ls").description("List top-level folders with nested children").option("-d, --dropped", "Include dropped folders").action(
|
|
1289
|
+
withErrorHandling(async (options) => {
|
|
1290
|
+
const of = new OmniFocus();
|
|
1291
|
+
const folders = await of.listFolders({ includeDropped: options.dropped });
|
|
1292
|
+
outputJson(folders);
|
|
1293
|
+
})
|
|
1294
|
+
);
|
|
1295
|
+
command.command("view <idOrName>").description("View folder details and children").option("-d, --dropped", "Include dropped child folders").action(
|
|
1296
|
+
withErrorHandling(async (idOrName, options) => {
|
|
1297
|
+
const of = new OmniFocus();
|
|
1298
|
+
const filters = { includeDropped: options.dropped };
|
|
1299
|
+
const folder = await of.getFolder(idOrName, filters);
|
|
1300
|
+
outputJson(folder);
|
|
1301
|
+
})
|
|
1302
|
+
);
|
|
1292
1303
|
return command;
|
|
1293
1304
|
}
|
|
1294
1305
|
|
|
1295
|
-
// src/
|
|
1306
|
+
// src/cli.ts
|
|
1296
1307
|
var program = new Command8();
|
|
1297
|
-
program.name("of").description("A command-line interface for OmniFocus on macOS").version("2.
|
|
1308
|
+
program.name("of").description("A command-line interface for OmniFocus on macOS").version("2.2.1").option("-c, --compact", "Minified JSON output (single line)").hook("preAction", (thisCommand) => {
|
|
1298
1309
|
const options = thisCommand.opts();
|
|
1299
1310
|
setOutputOptions({
|
|
1300
1311
|
compact: options.compact
|
|
@@ -1310,4 +1321,4 @@ program.addCommand(createFolderCommand());
|
|
|
1310
1321
|
program.parseAsync().catch(() => {
|
|
1311
1322
|
process.exit(1);
|
|
1312
1323
|
});
|
|
1313
|
-
//# sourceMappingURL=
|
|
1324
|
+
//# sourceMappingURL=cli.js.map
|