wasmer_cli/commands/journal/
export.rs

1use std::path::PathBuf;
2
3use clap::Parser;
4use wasmer_wasix::journal::{JournalPrintingMode, LogFileJournal, PrintingJournal, copy_journal};
5
6use crate::commands::CliCommand;
7
8/// Exports all the events in a journal to STDOUT as JSON data
9#[derive(Debug, Parser)]
10pub struct CmdJournalExport {
11    /// Path to the journal that will be printed
12    #[clap(index = 1)]
13    journal_path: PathBuf,
14}
15
16impl CliCommand for CmdJournalExport {
17    type Output = ();
18
19    fn run(self) -> Result<(), anyhow::Error> {
20        let journal = LogFileJournal::new(self.journal_path)?;
21        let printer = PrintingJournal::new(JournalPrintingMode::Json);
22        copy_journal(&journal, &printer)?;
23        Ok(())
24    }
25}