diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-12-22 06:43:36 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-12-22 06:43:36 +0100 |
commit | 622eafe6ede882b8957e5450cd63a318ec955190 (patch) | |
tree | 3ac6f4533d7997b3990728abb4334ca839a01817 | |
parent | d3de599ac01b133ce604aab7bd08fe60c484fac0 (diff) |
feat: add `--view` to `list`
-rw-r--r-- | app/Main.hs | 19 |
1 files 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 |