diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 47095b8..7701dd3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,15 +63,34 @@ fn parse_options(filename: &str) -> Vec<String> { push_option(&mut options, line.to_owned()); } } else { - let file = Command::new("pass") + let mut child = Command::new("pass") .arg("show") .arg(filename) - .output() - .expect("Error executing `pass`") - .stdout; + .stdout(std::process::Stdio::piped()) + .spawn() + .expect("Error executing `pass`"); - for line in String::from_utf8_lossy(&file).lines() { - push_option(&mut options, line.to_owned()); + child.wait().expect("Error waiting for `pass`"); + + let stdout = child.stdout.take().unwrap(); + + // let file = stdout; + // let stdout = child.stdout.unwrap(); + let file = io::BufReader::new(stdout); + + // let mut line = String::new(); + + // loop { + // let n_bytes = file.read_line(&mut line).unwrap(); + // if n_bytes == 0 { + // break; + // } + // + // push_option(&mut options, line.to_owned()); + // } + + for line in file.lines() { + push_option(&mut options, line.unwrap()); } } |