33 lines
910 B
Rust
33 lines
910 B
Rust
use clap::Parser;
|
|
use rs_pop_imap_importer::{config::Settings, imap_client::ImapClient};
|
|
|
|
/// List all email UIDs in IMAP inbox
|
|
#[derive(Parser, Debug)]
|
|
#[clap(version, about, long_about = None)]
|
|
struct Args {
|
|
/// Path to the .env file containing server configurations
|
|
#[clap(short, long, default_value = ".env")]
|
|
env_file: String,
|
|
}
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let args = Args::parse();
|
|
|
|
let settings = Settings::from_env_file(&args.env_file)?;
|
|
let mut imap_client = ImapClient::new(&settings.imap)?;
|
|
imap_client.login(&settings.imap)?;
|
|
imap_client.select_inbox()?;
|
|
|
|
println!("Fetching all messages...");
|
|
let messages = imap_client.fetch_all_messages()?;
|
|
|
|
println!("\nFound {} messages:", messages.len());
|
|
println!("UIDs:");
|
|
for (uid, _) in messages {
|
|
println!(" {}", uid);
|
|
}
|
|
|
|
imap_client.logout()?;
|
|
Ok(())
|
|
}
|