kratactl: rework to separate commands

This commit is contained in:
Alex Zenla
2024-03-15 15:59:18 +00:00
parent 31a43f9108
commit d66b6f80b9
10 changed files with 363 additions and 251 deletions

View File

@ -0,0 +1,30 @@
use anyhow::Result;
use clap::Parser;
use krata::control::{control_service_client::ControlServiceClient, DestroyGuestRequest};
use tonic::{transport::Channel, Request};
use crate::events::EventStream;
#[derive(Parser)]
pub struct DestroyCommand {
#[arg()]
guest: String,
}
impl DestroyCommand {
pub async fn run(
self,
mut client: ControlServiceClient<Channel>,
_events: EventStream,
) -> Result<()> {
let _ = client
.destroy_guest(Request::new(DestroyGuestRequest {
guest_id: self.guest.clone(),
}))
.await?
.into_inner();
println!("destroyed guest: {}", self.guest);
Ok(())
}
}