Add support for completing recurrence tasks

This commit is contained in:
2025-06-05 14:30:09 +02:00
parent 61e78a85d8
commit 2836d9bec6
10 changed files with 730 additions and 54 deletions

View File

@@ -1,9 +1,7 @@
import fs from "fs";
import dayjs from "dayjs";
import { createInterface } from "readline";
import { parse } from "../generated/grammar/task";
import { Task as DefaultTask } from "../model";
import { ParseResult } from "../types/grammar";
import { DynamicTask } from "../model";
import { Task, TaskPriority } from "../types/task";
import { jsMapper } from "../util/code";
@@ -75,7 +73,7 @@ async function readTasksFromFile(path: string): Promise<Task[]> {
for await (const line of lines) {
try {
const task = parseTask(line, path, lineNumber);
const task = DynamicTask.parse(line, path, lineNumber);
if(task) {
list.push(task);
@@ -96,17 +94,4 @@ async function readTasksFromFile(path: string): Promise<Task[]> {
return list;
}
/**
* Converts line to task model.
* If the line does not represent task, returns undefined.
*/
function parseTask(line: string, path: string, lineNumber: number): Task|undefined {
const item = parse(line) as ParseResult;
if (item.type === 'task') {
return new DefaultTask(path, line, lineNumber, item.data);
}
return undefined;
}