fuzzel-pass 0.1.2

A password-store frontend for auto-typing passwords
use super::Result;


shell!(Wtype, "/usr/bin/wtype");

impl Wtype {
    /// Sends keys input to the compositor.
    ///
    /// Refer to [`wtype` man page](https://man.archlinux.org/man/wtype.1.en)
    /// to see what parameters can be used to send keys
    ///
    /// * `keys` - `wtype` parameters.
    pub fn send_keys(&self, keys: Vec<String>) -> Result<()> {
        self.inner.exec(keys)?;
        Ok(())
    }
}

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn test_send_keys() {
        let wtype = mock_wtype();
        assert_eq!(
            Ok(()),
            wtype.send_keys(vec![
                "me@example.com".into(),
                "-k".into(),
                "Tab".into(),
                "Very Secret Password".into(),
                "Return".into()
            ])
        );
    }

    fn mock_wtype() -> Wtype {
        Wtype::new("test/scripts/mock-wtype".into())
    }
}