From 622eafe6ede882b8957e5450cd63a318ec955190 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Fri, 22 Dec 2023 06:43:36 +0100 Subject: feat: add `--view` to `list` --- app/Main.hs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 8ddf84e..8803f8b 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -53,7 +53,8 @@ data Cmd } | List { filters :: [Filter], - todo :: Bool + todo :: Bool, + view :: Bool } | Todo | View @@ -88,6 +89,7 @@ listCmd = List <$> filtersArg <*> todoArg + <*> viewArg todoCmd :: O.Parser Cmd todoCmd = @@ -139,7 +141,14 @@ todoArg :: O.Parser Bool todoArg = O.switch ( O.long "todo" - <> O.help "Run command `todo` on listed documents." + <> O.help "Run command `todo` on listed document(s)" + ) + +viewArg :: O.Parser Bool +viewArg = + O.switch + ( O.long "view" + <> O.help "Run command `view` on listed document(s)" ) data Filter @@ -157,7 +166,7 @@ main = do Args {cmd = Consume {keep, inputs}} -> mapM_ putStrLn =<< parMapM (consume1 keep) (map (cwd ) inputs) - Args {cmd = List {filters, todo = False}} -> do + Args {cmd = List {filters, todo = False, view = False}} -> do mapM_ ( \(Document {iFileName, index}) -> do if hasTag (Tag "todo" Nothing) index @@ -174,6 +183,10 @@ main = do processDocuments . applyFilters [FilterByTag "todo"] =<< getDocuments + Args {cmd = List {filters, view = True}} -> do + viewDocuments + . applyFilters filters + =<< getDocuments Args {cmd = View {indexNames}} -> do viewDocuments =<< mapM (readDocument . (<.> "json")) indexNames -- cgit v1.2.3