aboutsummaryrefslogtreecommitdiffstats
path: root/cli/app
diff options
context:
space:
mode:
Diffstat (limited to 'cli/app')
-rw-r--r--cli/app/Main.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/cli/app/Main.hs b/cli/app/Main.hs
index 4b166e7..12ba7c5 100644
--- a/cli/app/Main.hs
+++ b/cli/app/Main.hs
@@ -8,12 +8,14 @@
module Main where
+import ACMS.API.Query qualified
import ACMS.API.REST.Collection qualified
import Collection
import Control.Applicative ((<**>))
import Data.Aeson qualified as J
import Data.Aeson.Encode.Pretty qualified as J
import Data.ByteString.Lazy.Char8 qualified as LB
+import Data.ByteString.Lazy.UTF8 qualified as LB
import Data.Text qualified as T
import Options.Applicative qualified as O
@@ -24,13 +26,17 @@ newtype Args = Args
args :: O.Parser Args
args = Args <$> cmd_
-data Cmd = CollectionCmd CollectionCmd
+data Cmd
+ = CollectionCmd CollectionCmd
+ | QueryCmd
cmd_ :: O.Parser Cmd
cmd_ =
O.hsubparser . mconcat $
[ O.command "collection" . O.info collectionCmd $
- O.progDesc "Manage content collections"
+ O.progDesc "Manage content collections",
+ O.command "query" . O.info queryCmd $
+ O.progDesc "Manage content through queries"
]
data CollectionCmd
@@ -68,6 +74,9 @@ collectionArg :: O.Parser Collection
collectionArg =
Collection . T.pack <$> O.strArgument (O.metavar "COLLECTION_NAME")
+queryCmd :: O.Parser Cmd
+queryCmd = pure QueryCmd
+
main :: IO ()
main =
O.execParser (O.info (args <**> O.helper) O.idm) >>= \case
@@ -94,3 +103,7 @@ main =
CollectionSchema collection ->
LB.putStr . J.encodePretty @J.Value
=<< ACMS.API.REST.Collection.schema collection
+ Args {cmd = QueryCmd} ->
+ LB.putStr . J.encodePretty @J.Value
+ =<< ACMS.API.Query.query . LB.toString
+ =<< LB.getContents