use clap::Args;
#[derive(Debug, Clone)]
pub struct ImageArg {
pub name: String,
pub tag: String,
}
impl From<String> for ImageArg {
fn from(name: String) -> Self {
let parts = name.split(":").collect::<Vec<&str>>();
if parts.len() == 2 {
ImageArg {
name: parts[0].to_string(),
tag: parts[1].to_string()
}
} else {
ImageArg {
name,
tag: String::from("latest")
}
}
}
}
impl ToString for ImageArg {
fn to_string(&self) -> String {
format!("{}:{}", self.name, self.tag)
}
}
#[derive(Debug, Args)]
pub struct ImageInfoArgs {
pub image: ImageArg,
#[clap(long, default_value_t = String::from("linux"))]
pub os: String,
#[clap(long, default_value_t = String::from("amd64"))]
pub architecture: String
}
#[derive(Debug, Args)]
pub struct BuildImageArgs {
pub image: ImageArg,
#[clap(long, default_value_t = String::from("linux"))]
pub os: String,
#[clap(long, default_value_t = String::from("amd64"))]
pub architecture: String,
}
#[derive(Debug, Args)]
pub struct RemoveImageArgs {
pub image: ImageArg,
#[clap(long)]
pub prune: bool,
#[clap(long)]
pub os: Option<String>,
#[clap(long)]
pub architecture: Option<String>
}
#[derive(Debug, Args)]
pub struct ListImagesArgs {
#[clap(long)]
os: Option<String>,
#[clap(long)]
platform: Option<String>
}