import {Command, ParseContext, unwrapString} from "./command.js"; import {LexInput} from "../lexer.js"; import {StrVM} from "../vm.js"; import {Awaitable} from "../../util/types.js"; export class Lines extends Command<{}> { attemptParse(context: ParseContext): {} { return {} } getDisplayName(): string { return 'lines' } isParseCandidate(token: LexInput): boolean { return this.isKeyword(token, 'lines') } execute(vm: StrVM): Awaitable { return vm.replaceContextMatchingTerm({ destructure: sub => { return sub.split('\n') .map((line, idx) => ({ prefix: idx ? '\n' : undefined, value: line, })) }, }) } }