Skip to content

Commit 6ed445f

Browse files
committed
pass: Add sarch option
1 parent 8b332cf commit 6ed445f

File tree

1 file changed

+15
-5
lines changed
  • src/vonal_daemon/plugins/pass

1 file changed

+15
-5
lines changed

src/vonal_daemon/plugins/pass/mod.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Pass {
2626
Default::default()
2727
}
2828

29-
fn list_passwords(&self) -> Result<Vec<String>, Box<dyn Error>> {
29+
fn list_passwords(&self, keyword: &str) -> Result<Vec<String>, Box<dyn Error>> {
3030
let call = Command::new("bash")
3131
.stdout(Stdio::piped())
3232
.stderr(Stdio::piped())
@@ -41,7 +41,11 @@ impl Pass {
4141
}
4242

4343
let stdout = String::from_utf8_lossy(&call.stdout);
44-
let passwords = stdout.lines().map(ToString::to_string).collect();
44+
let passwords = stdout
45+
.lines()
46+
.filter(|name| name.contains(keyword))
47+
.map(ToString::to_string)
48+
.collect();
4549
Ok(passwords)
4650
}
4751

@@ -131,13 +135,19 @@ impl Plugin for Pass {
131135
ui: &mut egui::Ui,
132136
gl_window: &crate::windowing::GlutinWindowContext,
133137
) -> PluginFlowControl {
134-
if !query.starts_with("pass_plugin") {
138+
if !query.starts_with(&self.config_prefix) {
135139
return PluginFlowControl::Continue;
136140
}
137-
match self.list_passwords() {
141+
142+
let keyword = query
143+
.strip_prefix(&self.config_prefix)
144+
.unwrap_or_default()
145+
.trim();
146+
match self.list_passwords(keyword) {
138147
Ok(passwords) => {
139148
const NUMBER_OF_BUTTONS: usize = 2;
140-
self.list.update(ui.ctx(), passwords.len(), |_| NUMBER_OF_BUTTONS);
149+
self.list
150+
.update(ui.ctx(), passwords.len(), |_| NUMBER_OF_BUTTONS);
141151
ui.list(self.list, |mut ui| {
142152
for pw in passwords {
143153
ui.row(|mut ui| {

0 commit comments

Comments
 (0)