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 Word extends Command<WordData> {
execute(vm: StrVM, data: WordData): Awaitable<StrVM> {
// `word <cmd>` is equivalent to `words` -> `each <cmd>` -> `join`, so just do that
return vm.tapInPlace(ctx =>
ctx.replaceSubject(async sub =>
vm.runInChild(async (child, ctx) => {
await (new Words).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 Words).execute(child)
await (new Each).execute(child, { exec: data.exec })
await (new Join).execute(child, {})
})
}
}