use zond_engine::discover;
use crate::cli::DiscoverArgs;
use crate::command;
use crate::error::Error;
use crate::exit::Outcome;
use crate::render::{Phase, Renderer};
use crate::target;
pub(crate) async fn run(
args: &DiscoverArgs,
renderer: &mut dyn Renderer,
) -> Result<Outcome, Error> {
let mut config = command::engine_settings(args.engine.profile.as_deref())?.config;
args.engine.apply_to(&mut config);
let targets = target::resolve(&args.targets, !config.no_dns).await?;
let redaction = command::redaction(&config);
renderer.started(Phase::Discovery { targets: &targets }, redaction)?;
targets.apply_to(&mut config);
let (session, task) = discover(targets.into_ips(), &config).await?;
command::drive(session, task, renderer).await
}