From 6be3e106288f9340d62b83748e064f28cfac5b5a Mon Sep 17 00:00:00 2001 From: aaravm Date: Thu, 25 Jul 2024 17:26:25 +0530 Subject: [PATCH] added cancel --- cli/src/main.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cli/src/main.rs b/cli/src/main.rs index f4c1aab..be6a730 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -108,6 +108,12 @@ async fn run_cli(cmd: Command<'_>) -> Result<(), Box> { .about("get status of the task") .arg(arg!( "The id of the task which should be returned")) .arg_required_else_help(true), + ) + .subcommand( + Command::new("cancel") + .about("cancel the task") + .arg(arg!( "The id of the task which should be cancel")) + .arg_required_else_help(true), ), ); @@ -221,6 +227,25 @@ async fn run_cli(cmd: Command<'_>) -> Result<(), Box> { } }; } + if let Some(("cancel", sub)) = sub.subcommand() { + let mut config = Configuration::default(); + let id = sub.value_of("id").unwrap().to_string(); + + // let mut config = load_configuration(); + let funnel_url = ensure_funnel_running().await; + config.set_base_path(&funnel_url); + let transport = Transport::new(&config); + let task = Task::new(id, transport); + match task.cancel().await { + Ok(output) => { + println!("The new value is: {:?}",output); + }, + Err(e) => { + println!("Error creating Task instance: {:?}", e); + return Err(e); + } + }; + } } _ => {println!("TODO");}