You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1KB

  1. extern crate melib;
  2. use melib::backends::ImapType;
  3. use melib::AccountSettings;
  4. use melib::Result;
  5. fn main() -> Result<()> {
  6. let mut args = std::env::args().skip(1).collect::<Vec<String>>();
  7. if args.len() != 4 {
  8. eprintln!("Usage: imap_conn server_hostname server_username server_password server_port");
  9. std::process::exit(1);
  10. }
  11. let (a, b, c, d) = (
  12. std::mem::replace(&mut args[0], String::new()),
  13. std::mem::replace(&mut args[1], String::new()),
  14. std::mem::replace(&mut args[2], String::new()),
  15. std::mem::replace(&mut args[3], String::new()),
  16. );
  17. let set = AccountSettings {
  18. extra: [
  19. ("server_hostname".to_string(), a),
  20. ("server_username".to_string(), b),
  21. ("server_password".to_string(), c),
  22. ("server_port".to_string(), d),
  23. (
  24. "danger_accept_invalid_certs".to_string(),
  25. "true".to_string(),
  26. ),
  27. ]
  28. .iter()
  29. .cloned()
  30. .collect(),
  31. ..Default::default()
  32. };
  33. let mut imap = ImapType::new(&set, Box::new(|_| true));
  34. imap.shell();
  35. Ok(())
  36. }