From 02190c44f7072b4fdaca50836a583f955866f8de Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Fri, 11 Jan 2019 01:24:16 +0000 Subject: Check the DIALOG environment variable in default_backend This patch changes the logic in default_backend to respect the DIALOG environment variable that may contain the name of the backend to use. --- src/backends/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/backends') diff --git a/src/backends/mod.rs b/src/backends/mod.rs index b9cecd0..20cb8c1 100644 --- a/src/backends/mod.rs +++ b/src/backends/mod.rs @@ -31,3 +31,11 @@ pub trait Backend { /// Shows the given question dialog and returns the choice. fn show_question(&self, question: &super::Question) -> Result; } + +pub(crate) fn from_str(s: &str) -> Option> { + match s.to_lowercase().as_ref() { + "dialog" => Some(Box::new(Dialog::new())), + "zenity" => Some(Box::new(Zenity::new())), + _ => None, + } +} -- cgit v1.2.1