aboutsummaryrefslogtreecommitdiffstats
path: root/cli/app/Main.hs
diff options
context:
space:
mode:
authorLibravatar Kierán Meinhardt <kmein@posteo.de>2024-10-12 12:14:34 +0200
committerLibravatar Kierán Meinhardt <kmein@posteo.de>2024-10-12 12:14:37 +0200
commit0678aaf256203458cd2fd35f820fdcfc8724a709 (patch)
tree92945638e4cfed8ff7ce06772d7329e2d8444512 /cli/app/Main.hs
parent324ee5e50f88b5877f29164ca9c3e1c6c5161251 (diff)
cli: rephrase collection and item types
Diffstat (limited to 'cli/app/Main.hs')
-rw-r--r--cli/app/Main.hs46
1 files changed, 23 insertions, 23 deletions
diff --git a/cli/app/Main.hs b/cli/app/Main.hs
index 3584d72..eaabd0a 100644
--- a/cli/app/Main.hs
+++ b/cli/app/Main.hs
@@ -47,46 +47,46 @@ newtype Collection = Collection T.Text
deriving (Read)
data CollectionItem = CollectionItem
- { collectionName :: Collection,
- fileName :: T.Text
+ { collection :: Collection,
+ itemFileName :: T.Text
}
instance Read CollectionItem where
readPrec = R.lift do
- (Collection . T.pack -> collectionName) <- R.munch (/= '/')
+ (Collection . T.pack -> collection) <- R.munch (/= '/')
_ <- R.string "/"
- (T.pack -> fileName) <- do
- fileName <- R.munch (liftA2 (&&) (/= '.') (/= '/'))
+ (T.pack -> itemFileName) <- do
+ itemFileName <- R.munch (liftA2 (&&) (/= '.') (/= '/'))
fileExt <- R.string ".json"
- pure (fileName <> fileExt)
+ pure (itemFileName <> fileExt)
pure CollectionItem {..}
instance Show CollectionItem where
- show (CollectionItem {collectionName = Collection cn, fileName}) =
- show (cn <> "/" <> fileName)
+ show (CollectionItem {collection = Collection cn, itemFileName}) =
+ show (cn <> "/" <> itemFileName)
collectionCmd :: O.Parser Cmd
collectionCmd = do
fmap CollectionCmd . O.hsubparser . mconcat $
- [ O.command "add" . O.info (CollectionAdd <$> collectionNameArg) $
+ [ O.command "add" . O.info (CollectionAdd <$> collectionArg) $
O.progDesc "Add an entity",
- O.command "view" . O.info (CollectionView <$> collectionPathArg) $
+ O.command "view" . O.info (CollectionView <$> collectionItemArg) $
O.progDesc "View an entity",
- O.command "edit" . O.info (CollectionEdit <$> collectionPathArg) $
+ O.command "edit" . O.info (CollectionEdit <$> collectionItemArg) $
O.progDesc "Edit an entity",
- O.command "delete" . O.info (CollectionDelete <$> collectionPathArg) $
+ O.command "delete" . O.info (CollectionDelete <$> collectionItemArg) $
O.progDesc "Delete an entity",
--
- O.command "schema" . O.info (CollectionSchema <$> collectionNameArg) $
+ O.command "schema" . O.info (CollectionSchema <$> collectionArg) $
O.progDesc "Show the collection's schema"
]
-collectionPathArg :: O.Parser CollectionItem
-collectionPathArg =
+collectionItemArg :: O.Parser CollectionItem
+collectionItemArg =
O.argument O.auto (O.metavar "COLLECTION_PATH")
-collectionNameArg :: O.Parser Collection
-collectionNameArg =
+collectionArg :: O.Parser Collection
+collectionArg =
Collection . T.pack <$> O.strArgument (O.metavar "COLLECTION_NAME")
main :: IO ()
@@ -100,15 +100,15 @@ main =
=<< ACMS.API.REST.Collection.create cn
=<< J.throwDecode
=<< LB.getContents
- CollectionView CollectionItem {collectionName = Collection cn, fileName} ->
+ CollectionView CollectionItem {collection = Collection cn, itemFileName} ->
print
- =<< ACMS.API.REST.Collection.read cn fileName
- CollectionDelete CollectionItem {collectionName = Collection cn, fileName} ->
+ =<< ACMS.API.REST.Collection.read cn itemFileName
+ CollectionDelete CollectionItem {collection = Collection cn, itemFileName} ->
print
- =<< ACMS.API.REST.Collection.delete cn fileName
- CollectionEdit CollectionItem {collectionName = Collection cn, fileName} ->
+ =<< ACMS.API.REST.Collection.delete cn itemFileName
+ CollectionEdit CollectionItem {collection = Collection cn, itemFileName} ->
print
- =<< ACMS.API.REST.Collection.update cn fileName
+ =<< ACMS.API.REST.Collection.update cn itemFileName
=<< J.throwDecode
=<< LB.getContents
CollectionSchema (Collection cn) ->