Add basic support for task completion

This commit is contained in:
2025-06-04 18:46:20 +02:00
parent 46f09f2e13
commit 42d8f0db8b
17 changed files with 1087 additions and 68 deletions

View File

@@ -71,10 +71,11 @@ async function readTasksFromFile(path: string): Promise<Task[]> {
});
const list: Task[] = [];
let lineNumber = 1;
for await (const line of lines) {
try {
const task = parseTask(line);
const task = parseTask(line, path, lineNumber);
if(task) {
list.push(task);
@@ -87,6 +88,8 @@ async function readTasksFromFile(path: string): Promise<Task[]> {
}
console.warn(e.message);
console.warn("This line will be ignored. Please check the source and adjust it accordingly.");
} finally {
lineNumber++;
}
}
@@ -97,11 +100,11 @@ async function readTasksFromFile(path: string): Promise<Task[]> {
* Converts line to task model.
* If the line does not represent task, returns undefined.
*/
function parseTask(line: string): Task|undefined {
function parseTask(line: string, path: string, lineNumber: number): Task|undefined {
const item = parse(line) as ParseResult;
if (item.type === 'task') {
return new DefaultTask(item.data);
return new DefaultTask(path, line, lineNumber, item.data);
}
return undefined;