watchmen/commands/
reload.rs1use crate::common::{
2 arg::AddArgs,
3 config::Config,
4 handle::{Command, Request, Response},
5};
6use std::error::Error;
7
8use crate::{engine::send, utils::print_result};
9
10use super::task_to_request;
11
12pub async fn reload(args: AddArgs, config: Config) -> Result<(), Box<dyn Error>> {
13 let tasks = task_to_request(args, config.clone()).await?;
14 if tasks.is_empty() {
15 print_result(vec![Response::wrong("No task to reload".to_string())]).await;
16 } else {
17 let mut requests = Vec::new();
18 for task in tasks {
19 requests.push(Request {
20 command: Command::Reload(task),
21 });
22 }
23 print_result(send(config, requests).await?).await;
24 }
25 Ok(())
26}