Collapse child subtasks
mjdease opened this issue · comments
I have nested subtasks like so: parent > children > grandchildren
.
I want to collapse the grandchildren and not collapse the children so the output would show titles for parent > children
.
I expected configuring parent {collapse: false}
and children {collapse: true}
would work but nothing gets collapsed.
Example code:
new Listr([
{
title: 'setup',
task: () => {},
},
{
title: 'parent',
task: () => new Listr([
{
title: 'child',
task: () => new Listr([
{
title: 'grandchild1',
task: () => {},
},
{
title: 'grandchild2',
task: () => {},
},
]),
},
], {
collapse: true,
}),
},
{
title: 'teardown',
task: () => {},
},
], {
collapse: false,
}).run();
Expected Output:
✔ setup
✔ parent
✔ child
✔ teardown
Actual Output:
✔ setup
✔ parent
✔ child
✔ grandchild1
✔ grandchild2
✔ teardown
Any update on this?
The current implementation does not allow to customize the renderer options for subtasks or subsubtasks. The renderer of subtasks is hardcoded to listr-silent-renderer
here:
Line 112 in 2e5b0ba
Recursive rendering is handled by the root renderer (by default listr-update-renderer
). The particular code is in index.js
:
if ((task.isPending() || task.hasFailed() || options.collapse === false) && (task.hasFailed() || options.showSubtasks !== false) && task.subtasks.length > 0) {
output = output.concat(renderHelper(task.subtasks, options, level + 1));
}
You can see that the root options are passed down without modification. I fear you need to write a custom renderer for this use case.
See an example implementation here: make-github-pseudonymous-again/rejuvenate@885f905