Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add delete task subcommand #49

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading