nzz-downloader/cookie/src/main.rs

25 lines
551 B
Rust

use std::io::{self, Read};
use anyhow::Result;
use clap::Parser;
use nzz_cookie::cli::Config;
#[tokio::main]
async fn main() -> Result<()> {
let args = Config::parse();
let pw = read_pw().unwrap_or_else(|_| panic!("Provide the password via stdin"));
nzz_cookie::run(args, &pw).await?;
Ok(())
}
/// Read password from stdin.
fn read_pw() -> Result<String> {
let stdin = io::stdin();
let mut buffer = String::new();
stdin.lock().read_to_string(&mut buffer)?;
let cookie = buffer.trim();
Ok(cookie.to_string())
}