Skip to content

Commit da6fcf6

Browse files
committed
feat(tasks): add feature to convert subtask to task
1 parent b148521 commit da6fcf6

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/core/taskmaster/TaskMaster.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,23 @@ export class TaskMaster {
991991
);
992992
}
993993

994+
// TODO: validate
995+
/**
996+
* @description Converts an existing subtask to a task
997+
* @param hierarchicalId Hierarchical ID of the subtask to convert to a task
998+
*/
999+
public async convertSubtaskToTaskAsync(
1000+
hierarchicalId: string,
1001+
): Promise<void> {
1002+
await this.executeCommandAsync(
1003+
`Converting subtask ${hierarchicalId} to task...`,
1004+
`Subtask ${hierarchicalId} converted to task successfully!`,
1005+
`Failed to convert subtask ${hierarchicalId} to task`,
1006+
this._mainCommand,
1007+
["remove-subtask", `--id=${hierarchicalId}`, "--convert"],
1008+
);
1009+
}
1010+
9941011
// ==============================================
9951012
// Deleting Methods
9961013
// ==============================================

src/core/taskmaster/exec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,14 @@ export async function tmaiManageAsync() {
277277
await tmai.listAsync(tasks, TASKS_STATUSES.join(","), true, true);
278278
break;
279279
}
280+
case "tmai-convertsubtasktotask": {
281+
await tmai.listAsync(tasks, TASKS_STATUSES.join(","), true, true);
282+
const subtaskId = await askHierarchicalTaskIdAsync(subtasksIDs);
283+
await tmai.convertSubtaskToTaskAsync(subtaskId);
284+
tasks = await tmai.getTasksContentAsync();
285+
await tmai.listAsync(tasks, TASKS_STATUSES.join(","), true, true);
286+
break;
287+
}
280288
}
281289
break;
282290
}

src/prompt.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ export const tmaiUpdateTasksMenu_prompt = [
260260
name: `${emoji.get("pencil2")} Convert task to subtask`,
261261
value: "tmai-converttasktosubtask",
262262
},
263+
{
264+
name: `${emoji.get("pencil2")} Convert subtask to task`,
265+
value: "tmai-convertsubtasktotask",
266+
},
263267
],
264268
},
265269
];

0 commit comments

Comments
 (0)