Skip to content

Commit

Permalink
added cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
aaravm committed Jul 25, 2024
1 parent 215ae5a commit 6be3e10
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ async fn run_cli(cmd: Command<'_>) -> Result<(), Box<dyn Error>> {
.about("get status of the task")
.arg(arg!(<id> "The id of the task which should be returned"))
.arg_required_else_help(true),
)
.subcommand(
Command::new("cancel")
.about("cancel the task")
.arg(arg!(<id> "The id of the task which should be cancel"))
.arg_required_else_help(true),
),
);

Expand Down Expand Up @@ -221,6 +227,25 @@ async fn run_cli(cmd: Command<'_>) -> Result<(), Box<dyn Error>> {
}
};
}
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");}
Expand Down

0 comments on commit 6be3e10

Please sign in to comment.