Introduce TermOperator helper and refactor execute()s to use replaceSubjectMatchingTerm

This commit is contained in:
2026-02-09 23:49:30 -06:00
parent feba84051a
commit f36621c646
25 changed files with 243 additions and 159 deletions

View File

@@ -28,13 +28,10 @@ export class Line extends Command<LineData> {
execute(vm: StrVM, data: LineData): Awaitable<StrVM> {
// `line <cmd>` is equivalent to `lines` -> `each <cmd>` -> `join`, so just do that
return vm.tapInPlace(ctx =>
ctx.replaceSubject(async sub =>
vm.runInChild(async (child, ctx) => {
await (new Lines).execute(child, {})
await (new Each).execute(child, { exec: data.exec })
await (new Join).execute(child, {})
return ctx.getSubject()
})))
return vm.replaceContextFromChild(async child => {
await (new Lines).execute(child)
await (new Each).execute(child, { exec: data.exec })
await (new Join).execute(child, {})
})
}
}