Update 'fenv.hs'

master
Garrett Mills 3 years ago
parent 4df7458362
commit b71439326e

@ -11,10 +11,24 @@ data EnvFile =
| Entry EnvKey EnvValue EnvFile
deriving (Show,Eq,Read)
dispatch :: [(String, [String] -> IO ())]
dispatch = [
("get", cliGet),
("set", cliSet),
("unset", cliUnset)
]
main = do
let f = (Entry "foo" "bar" End)
putStrLn (show f)
cliGet :: [String] -> IO ()
cliGet (name:_) = do
env <- getEnvFile
case (getEntry env name) of
(Just value) -> putStrLn value
Nothing -> putStrLn "ERROR: No value defined"
setEntry :: EnvFile -> EnvKey -> EnvValue -> EnvFile
setEntry env key value = let env'=(removeEntry env key) in
(Entry key value env')

Loading…
Cancel
Save