From 3ee306d3d4bda52268f07df874070b65d171694e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Aug 2016 11:44:34 -0400 Subject: add --gui option --- UI.hs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'UI.hs') diff --git a/UI.hs b/UI.hs index 0ce87db..a97f3c1 100644 --- a/UI.hs +++ b/UI.hs @@ -10,5 +10,18 @@ import Control.Monad import UI.Zenity import UI.Readline -availableUI :: IO [UI] -availableUI = filterM isAvailable [zenityUI, readlineUI] +availableUIs :: IO [UI] +availableUIs = filterM isAvailable [zenityUI, readlineUI] + +selectUI :: Bool -> IO UI +selectUI needgui + | needgui = do + ok <- isAvailable zenityUI + if ok + then return zenityUI + else error "zenitty is not installed, GUI not available" + | otherwise = do + l <- availableUIs + case l of + (u:_) -> return u + [] -> error "Neither zenity nor the readline UI are available" -- cgit v1.2.3