Change json-stream export format to json-lines

This commit is contained in:
Joscha 2024-03-08 22:19:21 +01:00
parent 50be653244
commit 131b581880
3 changed files with 12 additions and 6 deletions

View file

@ -15,6 +15,10 @@ Procedure when bumping the version number:
## Unreleased
### Changed
- Renamed `json-stream` export format to `json-lines` (see <https://jsonlines.org/>)
- Changed `json-lines` file extension from `.json` to `.jsonl`
### Fixed
- Crash when window is too small while empty message editor is visible
- Mistakes in output and docs

View file

@ -14,8 +14,9 @@ pub enum Format {
Text,
/// Array of message objects in the same format as the euphoria API uses.
Json,
/// Message objects in the same format as the euphoria API uses, one per line.
JsonStream,
/// Message objects in the same format as the euphoria API uses, one per
/// line (https://jsonlines.org/).
JsonLines,
}
impl Format {
@ -23,14 +24,15 @@ impl Format {
match self {
Self::Text => "text",
Self::Json => "json",
Self::JsonStream => "json stream",
Self::JsonLines => "json lines",
}
}
fn extension(&self) -> &'static str {
match self {
Self::Text => "txt",
Self::Json | Self::JsonStream => "json",
Self::Json => "json",
Self::JsonLines => "jsonl",
}
}
}
@ -78,7 +80,7 @@ async fn export_room<W: Write>(
match format {
Format::Text => text::export(vault, out).await?,
Format::Json => json::export(vault, out).await?,
Format::JsonStream => json::export_stream(vault, out).await?,
Format::JsonLines => json::export_lines(vault, out).await?,
}
Ok(())
}

View file

@ -37,7 +37,7 @@ pub async fn export<W: Write>(vault: &EuphRoomVault, file: &mut W) -> anyhow::Re
Ok(())
}
pub async fn export_stream<W: Write>(vault: &EuphRoomVault, file: &mut W) -> anyhow::Result<()> {
pub async fn export_lines<W: Write>(vault: &EuphRoomVault, file: &mut W) -> anyhow::Result<()> {
let mut total = 0;
let mut last_msg_id = None;
loop {