ex-cli 1.20.1

Command line tool to find, filter, sort and list files.
Documentation
use crate::error::{MyError, MyResult};
use std::collections::hash_set::Iter;
use std::collections::HashSet;
use std::path::Path;

pub struct PasswordManager {
    config: Option<String>,
    passwords: HashSet<String>,
}

impl PasswordManager {
    pub fn new(config: &Option<String>) -> Self {
        let config = config.clone();
        let passwords = HashSet::new();
        Self { config, passwords }
    }

    pub fn config(&self) -> Option<&String> {
        self.config.as_ref()
    }

    pub fn passwords(&self) -> Iter<'_, String> {
        self.passwords.iter()
    }

    pub fn prompt(&mut self, path: &Path) -> MyResult<String> {
        let prompt = format!("Password for {}? ", path.display());
        let password = rpassword::prompt_password(prompt)
            .map_err(|_| MyError::Text(String::from("")))?;
        self.passwords.insert(password.clone());
        Ok(password)
    }
}