diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-01-08 17:16:49 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-01-08 20:55:54 +0100 |
commit | 474d92046f17a98f8979e55edaf75ca867d85b86 (patch) | |
tree | f62af448dcdd0547a88954fb514fbb1eba735f43 /src/backends | |
parent | 72200eb89e91019777f84c881caf5d3cc9649fbd (diff) | |
download | dialog-rs-474d92046f17a98f8979e55edaf75ca867d85b86.tar.gz dialog-rs-474d92046f17a98f8979e55edaf75ca867d85b86.tar.bz2 |
Add the Password dialog box
Diffstat (limited to 'src/backends')
-rw-r--r-- | src/backends/dialog.rs | 8 | ||||
-rw-r--r-- | src/backends/mod.rs | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/backends/dialog.rs b/src/backends/dialog.rs index da17ad1..939b8f3 100644 --- a/src/backends/dialog.rs +++ b/src/backends/dialog.rs @@ -3,7 +3,7 @@ use std::process; -use crate::{Choice, Error, Input, Message, Question, Result}; +use crate::{Choice, Error, Input, Message, Password, Question, Result}; /// The `dialog` backend. /// @@ -135,6 +135,12 @@ impl super::Backend for Dialog { .map(|_| ()) } + fn show_password(&self, password: &Password) -> Result<Option<String>> { + let args = vec!["--passwordbox", &password.text]; + self.execute(args, vec![], &password.title) + .and_then(get_stderr) + } + fn show_question(&self, question: &Question) -> Result<Choice> { let args = vec!["--yesno", &question.text]; self.execute(args, vec![], &question.title) diff --git a/src/backends/mod.rs b/src/backends/mod.rs index fd0ddcc..1d555e3 100644 --- a/src/backends/mod.rs +++ b/src/backends/mod.rs @@ -23,6 +23,9 @@ pub trait Backend { /// Shows the given message dialog. fn show_message(&self, message: &super::Message) -> Result<()>; + /// Shows the given password dialog and returns the password. + fn show_password(&self, password: &super::Password) -> Result<Option<String>>; + /// Shows the given question dialog and returns the choice. fn show_question(&self, question: &super::Question) -> Result<super::Choice>; } |