Skip to content

Commit

Permalink
add delete task subcommand (#49)
Browse files Browse the repository at this point in the history
* add delete task subcommand

* cargo fmt on everything
  • Loading branch information
trusch authored Jan 16, 2025
1 parent 17215bc commit 3a5658d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
38 changes: 35 additions & 3 deletions src/commands/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -342,3 +347,30 @@ pub async fn reschedule_task(
"secondary": resp.secondary
}))
}

pub async fn delete_task(
chain_args: &ChainArgs,
task_id: &str,
) -> Result<Value, Box<dyn std::error::Error>> {
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"
}))
}
5 changes: 4 additions & 1 deletion src/commands/workers.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3a5658d

Please sign in to comment.