use std::path::PathBuf;
use clap::Parser;
use wasmer_wasix::journal::{copy_journal, LogFileJournal};
use crate::commands::CliCommand;
#[derive(Debug, Parser)]
pub struct CmdExtractWhatMemory {
#[clap(index = 1)]
memory_file_path: PathBuf,
}
#[derive(clap::Subcommand, Debug)]
pub enum CmdExtractWhat {
Memory(CmdExtractWhatMemory),
}
#[derive(Debug, Parser)]
pub struct CmdJournalExtract {
#[clap(index = 1)]
journal_path: PathBuf,
#[clap(subcommand)]
what: CmdExtractWhat,
}
impl CliCommand for CmdJournalExtract {
type Output = ();
fn run(self) -> Result<(), anyhow::Error> {
let journal = LogFileJournal::new(&self.journal_path)?;
match self.what {
CmdExtractWhat::Memory(cmd) => {
let memory_file =
wasmer_wasix::journal::MemFileJournal::new(&cmd.memory_file_path)?;
copy_journal(&journal, &memory_file)?;
}
}
Ok(())
}
}