wasmer_cli/commands/journal/
extract.rs1use std::path::PathBuf;
2
3use clap::Parser;
4use wasmer_wasix::journal::{LogFileJournal, copy_journal};
5
6use crate::commands::CliCommand;
7
8#[derive(Debug, Parser)]
9pub struct CmdExtractWhatMemory {
10 #[clap(index = 1)]
12 memory_file_path: PathBuf,
13}
14
15#[derive(clap::Subcommand, Debug)]
17pub enum CmdExtractWhat {
18 Memory(CmdExtractWhatMemory),
19}
20
21#[derive(Debug, Parser)]
23pub struct CmdJournalExtract {
24 #[clap(index = 1)]
26 journal_path: PathBuf,
27
28 #[clap(subcommand)]
29 what: CmdExtractWhat,
30}
31
32impl CliCommand for CmdJournalExtract {
33 type Output = ();
34
35 fn run(self) -> Result<(), anyhow::Error> {
36 let journal = LogFileJournal::new(&self.journal_path)?;
37
38 match self.what {
39 CmdExtractWhat::Memory(cmd) => {
40 let memory_file =
41 wasmer_wasix::journal::MemFileJournal::new(&cmd.memory_file_path)?;
42 copy_journal(&journal, &memory_file)?;
43 }
44 }
45 Ok(())
46 }
47}