journal_tail: return typed Vec<JournalEntry>, remove Store::load from agent
- journal_tail returns Vec<JournalEntry> with key, content, created_at - load_startup_journal uses typed API, no more direct Store access - CLI does formatting, hippocampus returns data Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
419bb222b5
commit
063cf031d3
4 changed files with 62 additions and 47 deletions
|
|
@ -68,10 +68,17 @@ pub fn cmd_tail(n: usize, full: bool, provenance: Option<&str>, dedup: bool) ->
|
|||
}
|
||||
|
||||
pub async fn cmd_journal_tail(n: usize, full: bool, level: u8) -> Result<(), String> {
|
||||
let format = if full { Some("full") } else { Some("compact") };
|
||||
let result = memory::journal_tail(None, Some(n as u64), Some(level as u64), format, None).await
|
||||
let entries = memory::journal_tail(None, Some(n as u64), Some(level as u64), None).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
print!("{}", result);
|
||||
for entry in entries {
|
||||
if full {
|
||||
println!("--- {} ---", entry.key);
|
||||
println!("{}\n", entry.content);
|
||||
} else {
|
||||
let first_line = entry.content.lines().next().unwrap_or("(empty)");
|
||||
println!("{}: {}", entry.key, first_line);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue