Update examples
This commit is contained in:
11
testsuite/conf/simple/Mailrc.conf
Normal file
11
testsuite/conf/simple/Mailrc.conf
Normal file
@ -0,0 +1,11 @@
|
||||
import System.Directory
|
||||
|
||||
resource = mail {
|
||||
-- editor = do b <- doesFileExist "/usr/bin/emacs"
|
||||
-- return $ if b then "emacs" else "vi" ,
|
||||
editor = do b <- doesFileExist "/bin/sh"
|
||||
return "sh",
|
||||
|
||||
attribution = \name -> "Today, "++name++" wrote :"
|
||||
}
|
||||
|
28
testsuite/conf/simple/Mailrc.stub
Normal file
28
testsuite/conf/simple/Mailrc.stub
Normal file
@ -0,0 +1,28 @@
|
||||
module Mailrc ( resource ) where
|
||||
|
||||
import API
|
||||
|
||||
resource :: Interface
|
||||
resource = mail
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
4
testsuite/conf/simple/Makefile
Normal file
4
testsuite/conf/simple/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
TEST= conf/simple
|
||||
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
27
testsuite/conf/simple/api/API.hs
Normal file
27
testsuite/conf/simple/api/API.hs
Normal file
@ -0,0 +1,27 @@
|
||||
--
|
||||
-- the configuration file interface.
|
||||
--
|
||||
|
||||
module API where
|
||||
|
||||
data Color = Black | Grey | Green | Cyan | Yellow | Magenta | Red
|
||||
|
||||
data Interface = Interface {
|
||||
editor :: IO String,
|
||||
attribution :: String -> String,
|
||||
header_color :: Color,
|
||||
colorize :: [String],
|
||||
include :: Bool
|
||||
}
|
||||
|
||||
-- Default settings
|
||||
mail :: Interface
|
||||
mail = Interface {
|
||||
editor = return "vi",
|
||||
|
||||
attribution = (\user -> user ++ " wrote:"),
|
||||
header_color = Grey,
|
||||
colorize = [],
|
||||
include = True
|
||||
}
|
||||
|
22
testsuite/conf/simple/prog/Main.hs
Normal file
22
testsuite/conf/simple/prog/Main.hs
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
import System.Plugins
|
||||
import API
|
||||
|
||||
conf = "../Mailrc.conf"
|
||||
stub = "../Mailrc.stub"
|
||||
apipath = "../api"
|
||||
|
||||
main = do
|
||||
status <- makeWith conf stub ["-i"++apipath]
|
||||
o <- case status of
|
||||
MakeFailure e -> mapM_ putStrLn e >> error "failed"
|
||||
MakeSuccess _ o -> return o
|
||||
status <- load o [apipath] [] "resource"
|
||||
v <- case status of
|
||||
LoadFailure err -> mapM_ putStrLn err >> error "no"
|
||||
LoadSuccess _ v -> return v
|
||||
|
||||
user_editor <- editor v
|
||||
putStrLn user_editor
|
||||
makeCleaner o
|
||||
|
1
testsuite/conf/simple/prog/expected
Normal file
1
testsuite/conf/simple/prog/expected
Normal file
@ -0,0 +1 @@
|
||||
sh
|
Reference in New Issue
Block a user