use crate::core::{Result, Host};
use crate::tasks::{TaskRunner, exec};
use clap::ArgMatches;
pub fn run(hosts: Vec<Host>, matches: &ArgMatches) -> Result<()> {
let cmd_tmpl = get_command(matches.values_of("cmd"));
let parallel = matches.is_present("parallel");
let task = exec::Task::new(cmd_tmpl);
let res = hosts.run_task(&task, parallel)?;
println!("{}", res);
Ok(())
}
fn get_command(arg: Option<clap::Values<'_>>) -> String {
arg
.map(|vals| vals.collect::<Vec<_>>())
.map(|argv| shell_words::join(argv))
.unwrap()
}