diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-02-19 04:55:36 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-02-19 04:55:36 +0100 |
commit | bbe3b75bfd0767c61bcd436e843b9c785efd289f (patch) | |
tree | 5d3f62f0e8eb8b96f89175bfc43e443648ad4f8c /app | |
parent | 748f82632e5ab6fc2c2f7a6eedb1ac4c467ccb3e (diff) |
support `INSERT`, `DELETE`, `UPDATE`
Diffstat (limited to 'app')
-rw-r--r-- | app/Main.hs | 14 |
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 |