Tables 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+22/−3 lines, 3 files
Files
- Main.hs +9/−2
- README.md +12/−0
- Tables.cabal +1/−1
Main.hs view
@@ -17,17 +17,21 @@ import System.Environment import System.Exit +-- | Displayed from the "help" request in dispatch. allArgs = [("Add a Quill","add x to y as z | add x to y | add x as table | add x as list"), ("Remove a Quill","remove x from y | remove x"), ("Change a Quill","change x in y to z"), ("Get a quill", "get x from y | get x | list"), ("Combine Quills", "map x to y as z | combine x with y as z")]+ +-- | Dispatches the command line arguments. main = do arguments <- getArgs database <- Qm.fromFile (head arguments)- dispatch database (head arguments) arguments+ dispatch database (head arguments) (tail arguments) putStrLn "Done" +-- | Wraps a Quill error in the database by exiting, preventing database corruption. qError :: Qm.QuillStatus a -> IO a qError x = case x of (Qm.QuillSuccess a) -> return a -- FIXME make this handle the cases, not complain about them.@@ -37,8 +41,8 @@ (Qm.QuillMissing a) -> do putStrLn (a ++ " Missing from file. Exiting. Fix manually.") exitFailure- +-- | Handles the command-line arguments with destructuring. dispatch :: [Qm.Quill] -> String -> [String] -> IO () dispatch database fName ("change":x:"in":y:"to":z:w) = do qu <- qError (Qm.getQuill database y)@@ -133,14 +137,17 @@ putStrLn ("Did not recognize command: "++x) dispatch fName db xs +-- | Pretty print a table. ppTable :: (String, String) -> String ppTable (a,b) = Cm.flt [a," : ",b] +-- | List the contents of a Quill. listOff :: Qm.Quill -> IO () listOff x = case (snd x) of (Qm.Table _) -> putStrLn $ "Table " ++ (fst x) (Qm.List _) -> putStrLn $ "List " ++ (fst x) +-- | Evaluate Quill commands in an interactive Read-eval-print loop. repl fname dbase = do inp <- Cm.prompt "$ " dispatch fname dbase(Md.splitOn inp ' ')
README.md view
@@ -4,17 +4,29 @@ ## Argument rundown Tables [filename] get x from y+ Tables [filename] get x+ Tables [filename] add x as y+ Tables [filename] add x to y as z+ Tables [filename] remove x from y+ Tables [filename] remove x+ Tables [filename] change x in y to z+ Tables [filename] map x to y as z+ Tables [filename] combine x with y as z+ Tables [filename] file x+ Tables [filename] list+ Tables [filename] x and y and...+ Tables [filename] repl ## Table syntax
Tables.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.0+version: 0.1.0.1 -- A short (one-line) description of the package. synopsis: A client for Quill databases