1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
use clap::ArgMatches;

mod arg_parser;
mod discord;

pub async fn run(args: &ArgMatches<'_>) -> Result<(), Box<dyn std::error::Error>> {
    match args.subcommand_name() {
        Some("post") => {
            let snippet = arg_parser::retrieve_snippet(args)?;
            discord::execute_webhook(&snippet[..]).await?;
        }
        Some("set") => arg_parser::set_webhook_info(args).await?,
        _ => {
            eprintln!("There was no argument provided");
            std::process::exit(1);
        },
    }

    Ok(())
}