#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::missing_errors_doc)]

#[allow(clippy::too_many_lines)]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    #[cfg(feature = "docs")]
    {
        let markdown: String = clap_markdown::help_markdown::<ordinary::Cli>();
        std::fs::write(
            std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("DOCS.md"),
            markdown,
        )?;
    }

    #[cfg(not(feature = "docs"))]
    {
        use clap::Parser;
        use ordinary::{run, setup};

        let cli = ordinary::Cli::parse();

        setup(&cli)?;
        run(&cli).await?;
    }

    Ok(())
}
