summaryrefslogtreecommitdiffhomepage
path: root/UI/Readline.hs
diff options
context:
space:
mode:
Diffstat (limited to 'UI/Readline.hs')
-rw-r--r--UI/Readline.hs23
1 files changed, 14 insertions, 9 deletions
diff --git a/UI/Readline.hs b/UI/Readline.hs
index 50f2e99..086da1e 100644
--- a/UI/Readline.hs
+++ b/UI/Readline.hs
@@ -17,13 +17,18 @@ import qualified Data.ByteString.UTF8 as BU8
readlineUI :: UI
readlineUI = UI
{ isAvailable = queryTerminal stdInput
- , promptName = name
- , promptPassword = password
- , withProgress = progress
+ , showError = myShowError
+ , promptName = myPromptName
+ , promptPassword = myPromptPassword
+ , withProgress = myWithProgress
}
-name :: Title -> Desc -> Name -> (Name -> Maybe Problem) -> IO (Maybe Name)
-name title desc (Name suggested) checkproblem = do
+myShowError :: Desc -> IO ()
+myShowError desc = do
+ hPutStrLn stderr $ "Error: " ++ desc
+
+myPromptName :: Title -> Desc -> Name -> (Name -> Maybe Problem) -> IO (Maybe Name)
+myPromptName title desc (Name suggested) checkproblem = do
showTitle title
putStrLn desc
go
@@ -44,8 +49,8 @@ name title desc (Name suggested) checkproblem = do
go
Nothing -> return Nothing
-password :: Title -> Desc -> (Password -> Maybe Problem) -> IO (Maybe Password)
-password title desc checkproblem = bracket setup teardown (const go)
+myPromptPassword :: Title -> Desc -> (Password -> Maybe Problem) -> IO (Maybe Password)
+myPromptPassword title desc checkproblem = bracket setup teardown (const go)
where
setup = do
showTitle title
@@ -78,8 +83,8 @@ password title desc checkproblem = bracket setup teardown (const go)
putStrLn problem
go
-progress :: Title -> Desc -> ((Percent -> IO ()) -> IO ()) -> IO ()
-progress title desc a = bracket_ setup teardown (a sendpercent)
+myWithProgress :: Title -> Desc -> ((Percent -> IO ()) -> IO ()) -> IO ()
+myWithProgress title desc a = bracket_ setup teardown (a sendpercent)
where
setup = do
showTitle title