diff --git a/tasklite-core/app/Main.hs b/tasklite-core/app/Main.hs index 299367d..0bdf446 100644 --- a/tasklite-core/app/Main.hs +++ b/tasklite-core/app/Main.hs @@ -115,6 +115,8 @@ data Command | ListNew | ListOld | ListOpen + | ListModified + | ListModifiedOnly | ListDone | ListObsolete | ListDeletable @@ -462,6 +464,12 @@ commandParser conf = <> command "open" (toParserInfo (pure ListOpen) "List all open tasks by priority desc") + + <> command "modified" (toParserInfo (pure ListModified) + "List all tasks by modified UTC desc") + + <> command "modifiedonly" (toParserInfo (pure ListModifiedOnly) + "List tasks where modified UTC != creation UTC by modified UTC desc") -- All tasks due to no later than -- <> command "yesterday" @@ -853,6 +861,8 @@ executeCLiCommand conf now connection cmd = ListNew -> newTasks conf now connection ListOld -> listOldTasks conf now connection ListOpen -> openTasks conf now connection + ListModified -> modifiedTasks conf now connection AllItems + ListModifiedOnly -> modifiedTasks conf now connection ModifiedItemsOnly ListOverdue -> overdueTasks conf now connection ListRepeating -> listRepeating conf now connection ListRecurring -> listRecurring conf now connection diff --git a/tasklite-core/source/Lib.hs b/tasklite-core/source/Lib.hs index 9d0a656..1d03dc0 100644 --- a/tasklite-core/source/Lib.hs +++ b/tasklite-core/source/Lib.hs @@ -1572,6 +1572,36 @@ openTasks conf now connection = do pure $ formatTasks conf now tasks +modifiedTasks + :: Config + -> DateTime + -> Connection + -> ListModifiedFlag + -> IO (Doc AnsiStyle) +modifiedTasks conf now connection listModifiedFlag = do + tasks <- query_ connection $ Query + "select * from `tasks_view` \ + \order by `modified_utc` desc" + let + filterModified = + P.filter (\task -> + (removeNSec $ ulidTextToDateTime $ FullTask.ulid task) + /= (parseUtc $ FullTask.modified_utc task)) + + removeNSec :: Maybe DateTime -> Maybe DateTime + removeNSec mDateTime = + case mDateTime of + Just dateTime -> Just $ dateTime { dtTime = (dtTime dateTime) { todNSec = 0 } } + Nothing -> Nothing + + filteredTasks = + case listModifiedFlag of + AllItems -> tasks + ModifiedItemsOnly -> filterModified tasks + + pure $ formatTasks conf now filteredTasks + + overdueTasks :: Config -> DateTime -> Connection -> IO (Doc AnsiStyle) overdueTasks conf now connection = do tasks <- query_ connection $ Query diff --git a/tasklite-core/source/Utils.hs b/tasklite-core/source/Utils.hs index 0465e0e..b3d88c4 100644 --- a/tasklite-core/source/Utils.hs +++ b/tasklite-core/source/Utils.hs @@ -27,6 +27,9 @@ type TagText = Text data Filter a = NoFilter | Only a deriving (Eq, Ord, Show) +data ListModifiedFlag = AllItems | ModifiedItemsOnly + deriving (Eq, Show) + (<++>) :: Doc ann -> Doc ann -> Doc ann x <++> y =