Add new restructureOrLines match target + update join command to use it

This commit is contained in:
2026-03-05 10:09:26 -06:00
parent d296646d4f
commit c9f41c2905
3 changed files with 27 additions and 12 deletions

View File

@@ -26,6 +26,15 @@ export const joinDestructured = (val: StrDestructured['value']): string =>
.map(part => `${part.prefix || ''}${part.value}`)
.join('')
export const destructureToLines = (val: string): StrDestructured['value'] => val
.split('\n')
.map((line, idx) => {
if ( idx ) {
return { prefix: '\n', value: line }
}
return { value: line }
})
export type StrRVal =
{ term: 'string', value: string, literal?: true }
| { term: 'int', value: number }

View File

@@ -20,7 +20,7 @@ export class Join extends Command<{ with?: StrTerm }> {
execute(vm: StrVM, data: { with?: StrTerm }): Awaitable<StrVM> {
return vm.replaceContextMatchingTerm(ctx => ({
restructure: parts => {
restructureOrLines: parts => {
if ( data.with ) {
return parts
.map(part => part.value)