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