use aiken_project::watch::{self, watch_project, with_project};
use std::{path::PathBuf, process};
#[derive(clap::Args)]
#[clap(disable_version_flag(true))]
pub struct Args {
directory: Option<PathBuf>,
#[clap(short = 'D', long)]
deny: bool,
#[clap(short = 'S', long)]
silent: bool,
#[clap(short, long)]
watch: bool,
#[clap(long)]
include_dependencies: bool,
#[clap(short = 'o', long)]
destination: Option<PathBuf>,
}
pub fn exec(
Args {
directory,
deny,
silent,
watch,
destination,
include_dependencies,
}: Args,
) -> miette::Result<()> {
let result = if watch {
watch_project(directory.as_deref(), watch::default_filter, 500, |p| {
p.docs(destination.clone(), include_dependencies)
})
} else {
with_project(directory.as_deref(), deny, silent, true, |p| {
p.docs(destination.clone(), include_dependencies)
})
};
result.map_err(|_| process::exit(1))
}