diff --git a/src/commands/tasks.rs b/src/commands/tasks.rs index 1e73126..d36e6af 100644 --- a/src/commands/tasks.rs +++ b/src/commands/tasks.rs @@ -54,9 +54,8 @@ impl Command { ) .await } - Subcommand::Reschedule { id } => { - reschedule_task(&self.chain_args, id).await - } + Subcommand::Reschedule { id } => reschedule_task(&self.chain_args, id).await, + Subcommand::Delete { id } => delete_task(&self.chain_args, id).await, }?; print_object(format, &value) } @@ -129,6 +128,12 @@ enum Subcommand { /// The ID of the task to reschedule. id: String, }, + + /// Delete a task. + Delete { + /// The ID of the task to delete. + id: String, + }, } /// Lists all tasks. @@ -342,3 +347,30 @@ pub async fn reschedule_task( "secondary": resp.secondary })) } + +pub async fn delete_task( + chain_args: &ChainArgs, + task_id: &str, +) -> Result> { + let mut client = connect_to_gevulot(chain_args).await?; + let me = client + .base_client + .write() + .await + .address + .clone() + .ok_or("No address found, did you set a mnemonic?")?; + + client + .tasks + .delete(gevulot_rs::proto::gevulot::gevulot::MsgDeleteTask { + creator: me.clone(), + id: task_id.to_string(), + }) + .await?; + + Ok(serde_json::json!({ + "status": "success", + "message": "Task deleted successfully" + })) +} diff --git a/src/commands/workers.rs b/src/commands/workers.rs index a78c68e..a00d885 100644 --- a/src/commands/workers.rs +++ b/src/commands/workers.rs @@ -1,4 +1,7 @@ -use gevulot_rs::builders::{ByteSize, ByteUnit, MsgAnnounceWorkerExitBuilder, MsgCreateWorkerBuilder, MsgDeleteWorkerBuilder}; +use gevulot_rs::builders::{ + ByteSize, ByteUnit, MsgAnnounceWorkerExitBuilder, MsgCreateWorkerBuilder, + MsgDeleteWorkerBuilder, +}; use patharg::InputArg; use serde_json::Value; use std::path::Path; diff --git a/src/main.rs b/src/main.rs index c9c1ab2..489b2b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -140,7 +140,6 @@ pub enum Command { /// Build a VM image from a container, rootfs directory, or Containerfile. Build(build::BuildArgs), - } /// Main entry point for the Gevulot Control CLI application.