aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 8622317..945bfc9 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -49,6 +49,8 @@ serveCmd =
main :: IO ()
main = do
setCurrentDirectory "./data"
+ let root = "."
+ ref = "HEAD"
A.execParser (A.info (args <**> A.helper) A.idm) >>= \case
Args {cmd = Repl} -> do
-- TODO Catch `ParseError` exception
@@ -60,7 +62,12 @@ main = do
-- @topic repl
R.evalRepl
(const . pure $ ">>> ")
- (liftIO . query' . fromString)
+ ( liftIO
+ . (mapM_ (LB.putStrLn . J.encode) =<<)
+ . Q.withStore root ref
+ . Q.query
+ . fromString
+ )
([])
(Just ':')
(Just "paste")
@@ -74,11 +81,8 @@ main = do
q <-
fromString @Q.Query . LB.toString
<$> W.lazyRequestBody req
- r <- Q.query q
+ r <- liftIO $ Q.withStore root ref (Q.query q)
respond . W.responseLBS W.status200 [] $
J.encode r
| otherwise ->
respond $ W.responseLBS W.status200 [] "OK"
-
-query' :: Q.Query -> IO ()
-query' q = mapM_ (LB.putStrLn . J.encode) =<< Q.query q