use arboard::Clipboard;

pub struct Wclip {
    clipboard: Clipboard,
}

impl Wclip {
    pub fn new() -> Wclip {
        Wclip {
            clipboard: Clipboard::new().unwrap(),
        }
    }

    pub fn set(&mut self, text: &str) {
        self.clipboard.set_text(text).unwrap();
    }

    pub fn get(&mut self) -> Option<String> {
        if let Ok(text) = self.clipboard.get_text() {
            Some(text)
        } else {
            None
        }
    }
}
