use std::{env, process::ExitCode, thread::sleep, time::Duration};

fn parse_args(args: &[String]) -> Option<Duration> {
    if args.len() != 2 {
        return None;
    }

    let ms: u64 = args[1].parse().ok()?;
    Some(Duration::from_millis(ms))
}

fn main() -> ExitCode {
    let args = env::args().collect::<Vec<_>>();
    let t = match parse_args(&args) {
        Some(t) => t,
        None => {
            eprintln!("Usage: {} <ms>", args[0]);
            return ExitCode::FAILURE;
        }
    };

    sleep(t);

    ExitCode::SUCCESS
}
