Add basic support for task completion
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user