1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-05-09 00:56:14 +02:00
youki/src/commands/state.rs
2021-10-22 21:55:16 +02:00

25 lines
603 B
Rust

use std::fs;
use std::path::PathBuf;
use anyhow::Result;
use clap::Clap;
use crate::container::Container;
/// Show the container state
#[derive(Clap, Debug)]
pub struct State {
#[clap(required = true)]
pub container_id: String,
}
impl State {
pub fn exec(&self, root_path: PathBuf) -> Result<()> {
let root_path = fs::canonicalize(root_path)?;
let container_root = root_path.join(&self.container_id);
let container = Container::load(container_root)?;
println!("{}", serde_json::to_string_pretty(&container.state)?);
std::process::exit(0);
}
}