goldboot/cli/cmd/
image.rs1use std::process::ExitCode;
2
3use crate::library::ImageLibrary;
4use chrono::TimeZone;
5
6use ubyte::ToByteUnit;
7
8pub fn run(cmd: super::Commands) -> ExitCode {
9 match cmd {
10 super::Commands::Image { command } => match &command {
11 super::ImageCommands::List {} => {
12 let images = ImageLibrary::find_all().unwrap();
13
14 println!("Image Name Image Size Build Date Image ID Description");
15 for image in images {
16 println!(
17 "{:15} {:12} {:31} {:12} {}",
18 std::str::from_utf8(&image.primary_header.name).unwrap(),
19 image.primary_header.size.bytes().to_string(),
20 chrono::Utc
21 .timestamp(image.primary_header.timestamp as i64, 0)
22 .to_rfc2822(),
23 &image.id[0..12],
24 "TODO",
25 );
26 }
27 ExitCode::SUCCESS
28 }
29 super::ImageCommands::Info { image } => {
30 if let Some(image) = image {
31 let _image = ImageLibrary::find_by_id(image).unwrap();
32 }
34
35 ExitCode::SUCCESS
36 }
37 },
38 _ => panic!(),
39 }
40}