// A plain-text email: the body filled at 60 columns, a numbered list with hanging indents, and the message replied to quoted.
//
//   quillo run text_wrap.qwe      then open http://localhost:8080/reply.txt

use "text_wrap.qwer"

let original = "Could you send the invoice for October again? The one I got has the old address on it, and our accountant needs the new one before the end of the month.\n\nThanks, Ada"

let steps = ["Open Settings and choose Billing, then pick the invoice you want to download again.", "Change the address under Company details; the next invoices will carry it."]

route GET /reply.txt {
    let body = wrap_fill("Hi Ada, here is the October invoice again with the new address. I have also changed it for the invoices to come, so this will not happen again.", 60)?
    let list = enumerate(steps) | map((p) => wrap_hanging(p[1], 60, `${p[0] + 1}. `, "   ")?)
    let text = `${body}\n\n${join(list, "\n")}\n\nOn 28 October, Ada wrote:\n${wrap_quote(original, 60)?}\n`
    respond(200, text, { "content-type": "text/plain; charset=utf-8" })
}

route GET /lines ? { width: int = 20 } = wrap_lines("The quick brown fox jumps over the lazy dog.", width)?
