Change json-stream export format to json-lines
This commit is contained in:
parent
50be653244
commit
131b581880
3 changed files with 12 additions and 6 deletions
|
|
@ -15,6 +15,10 @@ Procedure when bumping the version number:
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Renamed `json-stream` export format to `json-lines` (see <https://jsonlines.org/>)
|
||||||
|
- Changed `json-lines` file extension from `.json` to `.jsonl`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Crash when window is too small while empty message editor is visible
|
- Crash when window is too small while empty message editor is visible
|
||||||
- Mistakes in output and docs
|
- Mistakes in output and docs
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,9 @@ pub enum Format {
|
||||||
Text,
|
Text,
|
||||||
/// Array of message objects in the same format as the euphoria API uses.
|
/// Array of message objects in the same format as the euphoria API uses.
|
||||||
Json,
|
Json,
|
||||||
/// Message objects in the same format as the euphoria API uses, one per line.
|
/// Message objects in the same format as the euphoria API uses, one per
|
||||||
JsonStream,
|
/// line (https://jsonlines.org/).
|
||||||
|
JsonLines,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Format {
|
impl Format {
|
||||||
|
|
@ -23,14 +24,15 @@ impl Format {
|
||||||
match self {
|
match self {
|
||||||
Self::Text => "text",
|
Self::Text => "text",
|
||||||
Self::Json => "json",
|
Self::Json => "json",
|
||||||
Self::JsonStream => "json stream",
|
Self::JsonLines => "json lines",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extension(&self) -> &'static str {
|
fn extension(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Text => "txt",
|
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 {
|
match format {
|
||||||
Format::Text => text::export(vault, out).await?,
|
Format::Text => text::export(vault, out).await?,
|
||||||
Format::Json => json::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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ pub async fn export<W: Write>(vault: &EuphRoomVault, file: &mut W) -> anyhow::Re
|
||||||
Ok(())
|
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 total = 0;
|
||||||
let mut last_msg_id = None;
|
let mut last_msg_id = None;
|
||||||
loop {
|
loop {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue