From 167be01245dbbebc46dc109a8cfaf9456fa870a2 Mon Sep 17 00:00:00 2001 From: Louis-Guillaume Gagnon Date: Wed, 4 Sep 2013 16:02:53 -0400 Subject: [PATCH] Modify: check is filters are ok and entry exists --- src/Modify.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Modify.hs b/src/Modify.hs index 7138cda..07909d2 100644 --- a/src/Modify.hs +++ b/src/Modify.hs @@ -24,14 +24,24 @@ module Modify ( import Data.Char (isDigit) import Tools.Constants +import Tools.Filter (tryGetFilters) import Tools.Operation (isHelp) +import Tools.SQL (getEntry) modify :: [String] -> IO () modify [] = error errTooFew modify (f:[]) = if isHelp f then putStrLn usageModify else error errTooFew modify (id:fs) = if or (map (not . isDigit) id) then error $ "modify: invalid id: " ++ id - else return () + else do entry <- getEntry $ read id + case entry of + Left msg -> error $ "modify: " ++ msg + Right row -> do filters <- tryGetFilters fs + case filters of + Left msg -> error $ "modify: " ++ msg + --Right fs' -> doModify row fs' + Right fs' -> putStrLn "not yet implemented" + errTooFew :: String errTooFew = "modify: too few arguments ('" ++ progName ++ " modify help' for help)" -- 2.11.4.GIT