Skip to content

Add pipe-friendly output / export helpers #4

Description

@swinton

There's no way to get data out of the REPL into other tools today. Export helpers would enable inbox analysis in spreadsheets, databases, or CLI pipelines.

Proposed API

// Export messages to JSON (stdout or file)
await toJSON(await messages('from:boss@example.com'))

// Export messages to CSV
await toCSV(await messages('from:boss@example.com'))

// Optionally write to a file
await toCSV(await messages('label:receipts'), 'receipts.csv')

Notes

  • toJSON could just be a thin wrapper around JSON.stringify with pretty-printing
  • toCSV should flatten the key fields: id, from, to, subject, date — pairs naturally with decode() added in Add send, reply, and draft capability #2
  • Writing to stdout makes it pipeable: ./repl.js < script.js > output.csv
  • No new dependencies needed for JSON; CSV can be hand-rolled for the simple flat structure we need

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions