@mindtnv/todoist-cli 0.4.0 → 0.5.0
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/package.json +6 -6
- package/src/api/activity.ts +8 -0
- package/src/api/client.ts +214 -0
- package/src/api/comments.ts +18 -0
- package/src/api/completed.ts +15 -0
- package/src/api/labels.ts +18 -0
- package/src/api/projects.ts +22 -0
- package/src/api/sections.ts +20 -0
- package/src/api/stats.ts +38 -0
- package/src/api/tasks.ts +34 -0
- package/src/api/types.ts +202 -0
- package/src/cli/auth.ts +40 -0
- package/src/cli/commands/task/add.ts +328 -0
- package/src/cli/commands/task/complete.ts +62 -0
- package/src/cli/commands/task/delete.ts +62 -0
- package/src/cli/commands/task/helpers.ts +289 -0
- package/src/cli/commands/task/index.ts +27 -0
- package/src/cli/commands/task/list.ts +151 -0
- package/src/cli/commands/task/move.ts +49 -0
- package/src/cli/commands/task/reopen.ts +43 -0
- package/src/cli/commands/task/show.ts +115 -0
- package/src/cli/commands/task/update.ts +122 -0
- package/src/cli/comment.ts +83 -0
- package/src/cli/completed.ts +87 -0
- package/src/cli/completion.ts +360 -0
- package/src/cli/filter.ts +115 -0
- package/src/cli/index.ts +638 -0
- package/src/cli/label.ts +120 -0
- package/src/cli/log.ts +57 -0
- package/src/cli/matrix.ts +100 -0
- package/src/cli/plugin-loader.ts +38 -0
- package/src/cli/plugin.ts +289 -0
- package/src/cli/project.ts +172 -0
- package/src/cli/review.ts +116 -0
- package/src/cli/section.ts +98 -0
- package/src/cli/stats.ts +62 -0
- package/src/cli/template.ts +89 -0
- package/src/config/index.ts +229 -0
- package/src/plugins/api-proxy.ts +70 -0
- package/src/plugins/extension-registry.ts +53 -0
- package/src/plugins/hook-registry.ts +36 -0
- package/src/plugins/loader.ts +200 -0
- package/src/plugins/marketplace-types.ts +55 -0
- package/src/plugins/marketplace.ts +576 -0
- package/src/plugins/palette-registry.ts +21 -0
- package/src/plugins/storage.ts +101 -0
- package/src/plugins/types.ts +226 -0
- package/src/plugins/view-registry.ts +19 -0
- package/src/ui/App.tsx +234 -0
- package/src/ui/components/Breadcrumb.tsx +18 -0
- package/src/ui/components/CommandPalette.tsx +237 -0
- package/src/ui/components/ConfirmDialog.tsx +28 -0
- package/src/ui/components/EditTaskModal.tsx +484 -0
- package/src/ui/components/HelpOverlay.tsx +195 -0
- package/src/ui/components/InputPrompt.tsx +109 -0
- package/src/ui/components/LabelPicker.tsx +110 -0
- package/src/ui/components/ModalManager.tsx +275 -0
- package/src/ui/components/ProjectPicker.tsx +95 -0
- package/src/ui/components/Sidebar.tsx +282 -0
- package/src/ui/components/SortMenu.tsx +77 -0
- package/src/ui/components/StatusBar.tsx +67 -0
- package/src/ui/components/TaskList.tsx +258 -0
- package/src/ui/components/TaskRow.tsx +105 -0
- package/src/ui/hooks/useKeyboardHandler.ts +291 -0
- package/src/ui/hooks/useStatusMessage.ts +32 -0
- package/src/ui/hooks/useTaskOperations.ts +558 -0
- package/src/ui/hooks/useUndoSystem.ts +218 -0
- package/src/ui/views/ActivityView.tsx +213 -0
- package/src/ui/views/CompletedView.tsx +337 -0
- package/src/ui/views/StatsView.tsx +178 -0
- package/src/ui/views/TaskDetailView.tsx +438 -0
- package/src/ui/views/TasksView.tsx +851 -0
- package/src/utils/colors.ts +27 -0
- package/src/utils/date-format.ts +54 -0
- package/src/utils/errors.ts +159 -0
- package/src/utils/exit.ts +11 -0
- package/src/utils/format.ts +46 -0
- package/src/utils/open-url.ts +9 -0
- package/src/utils/output.ts +29 -0
- package/src/utils/quick-add.ts +202 -0
- package/src/utils/resolve.ts +359 -0
- package/src/utils/sorting.ts +27 -0
- package/src/utils/validation.ts +88 -0
- package/dist/index.js +0 -11355
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { getFilters, saveFilter, removeFilter } from "../config/index.ts";
|
|
4
|
+
import { getTasks } from "../api/tasks.ts";
|
|
5
|
+
import { printTaskTable } from "./commands/task/index.ts";
|
|
6
|
+
import { handleError } from "../utils/errors.ts";
|
|
7
|
+
import { cliExit } from "../utils/exit.ts";
|
|
8
|
+
|
|
9
|
+
export function registerFilterCommand(program: Command): void {
|
|
10
|
+
const filter = program
|
|
11
|
+
.command("filter")
|
|
12
|
+
.description("Manage saved filters");
|
|
13
|
+
|
|
14
|
+
filter
|
|
15
|
+
.command("save")
|
|
16
|
+
.description("Save a named filter")
|
|
17
|
+
.argument("<name>", "Filter name (used as shortcut)")
|
|
18
|
+
.argument("<query>", "Todoist filter query")
|
|
19
|
+
.action((name: string, query: string) => {
|
|
20
|
+
saveFilter(name, query);
|
|
21
|
+
console.log(chalk.green(`Filter saved: ${chalk.bold(name)} → "${query}"`));
|
|
22
|
+
console.log(chalk.dim(`Run with: todoist filter run ${name}`));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
filter
|
|
26
|
+
.command("list")
|
|
27
|
+
.description("List saved filters")
|
|
28
|
+
.action(() => {
|
|
29
|
+
const filters = getFilters();
|
|
30
|
+
const entries = Object.entries(filters);
|
|
31
|
+
if (entries.length === 0) {
|
|
32
|
+
console.log(chalk.dim("No saved filters."));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
console.log(chalk.bold("Saved Filters"));
|
|
36
|
+
console.log(chalk.dim("-".repeat(50)));
|
|
37
|
+
for (const [name, query] of entries) {
|
|
38
|
+
console.log(` ${chalk.cyan(name)} → ${query}`);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
filter
|
|
43
|
+
.command("delete")
|
|
44
|
+
.description("Delete a saved filter")
|
|
45
|
+
.argument("<name>", "Filter name")
|
|
46
|
+
.action((name: string) => {
|
|
47
|
+
if (removeFilter(name)) {
|
|
48
|
+
console.log(chalk.green(`Filter "${name}" deleted.`));
|
|
49
|
+
} else {
|
|
50
|
+
console.error(chalk.red(`Filter "${name}" not found.`));
|
|
51
|
+
cliExit(1);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
filter
|
|
56
|
+
.command("run")
|
|
57
|
+
.description("Run a saved filter")
|
|
58
|
+
.argument("<name>", "Filter name")
|
|
59
|
+
.option("-q, --quiet", "Print only task IDs")
|
|
60
|
+
.option("--json <fields>", "Output JSON with specified fields")
|
|
61
|
+
.option("--csv", "Output in CSV format")
|
|
62
|
+
.option("--tsv", "Output in TSV format")
|
|
63
|
+
.option("--count", "Show only the count")
|
|
64
|
+
.action(async (name: string, opts: { quiet?: boolean; json?: string; csv?: boolean; tsv?: boolean; count?: boolean }) => {
|
|
65
|
+
try {
|
|
66
|
+
const filters = getFilters();
|
|
67
|
+
const query = filters[name];
|
|
68
|
+
if (!query) {
|
|
69
|
+
console.error(chalk.red(`Filter "${name}" not found.`));
|
|
70
|
+
const available = Object.keys(filters);
|
|
71
|
+
if (available.length > 0) {
|
|
72
|
+
console.error(chalk.dim(`Available: ${available.join(", ")}`));
|
|
73
|
+
}
|
|
74
|
+
cliExit(1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const tasks = await getTasks({ filter: query });
|
|
78
|
+
|
|
79
|
+
if (opts.count) {
|
|
80
|
+
console.log(String(tasks.length));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (opts.quiet) {
|
|
85
|
+
for (const t of tasks) console.log(t.id);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (opts.json !== undefined) {
|
|
90
|
+
const fields = opts.json.split(",").map(f => f.trim());
|
|
91
|
+
const data = tasks.map(t => {
|
|
92
|
+
const obj: Record<string, unknown> = {};
|
|
93
|
+
for (const f of fields) {
|
|
94
|
+
if (f in t) obj[f] = (t as unknown as Record<string, unknown>)[f];
|
|
95
|
+
}
|
|
96
|
+
return obj;
|
|
97
|
+
});
|
|
98
|
+
console.log(JSON.stringify(data, null, 2));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (opts.csv || opts.tsv) {
|
|
103
|
+
const { formatTasksDelimited } = await import("../utils/output.ts");
|
|
104
|
+
console.log(formatTasksDelimited(tasks, opts.tsv ? "\t" : ","));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log(chalk.bold(`Filter: ${name}`) + chalk.dim(` (${query})`));
|
|
109
|
+
console.log("");
|
|
110
|
+
printTaskTable(tasks);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
handleError(err);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|