Add support for completing recurrence tasks
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user