use clap::Subcommand;
use quicknode_sdk::admin::CreateTagRequest;
use crate::context::Ctx;
use crate::errors::CliError;
#[derive(Debug, Subcommand)]
pub enum TagCmd {
Add {
id: String,
label: String,
},
Remove {
id: String,
tag_id: String,
},
}
pub async fn run(cmd: TagCmd, ctx: Ctx) -> Result<(), CliError> {
match cmd {
TagCmd::Add { id, label } => {
let req = CreateTagRequest {
label: Some(label.clone()),
};
ctx.sdk.admin.create_tag(&id, &req).await?;
ctx.out.note(&format!("✓ Tagged {id} with {label:?}"));
}
TagCmd::Remove { id, tag_id } => {
ctx.sdk.admin.delete_tag(&id, &tag_id).await?;
ctx.out.note(&format!("✓ Removed tag {tag_id} from {id}"));
}
}
Ok(())
}