summaryrefslogtreecommitdiff
path: root/Omni
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-11-09 08:17:45 -0500
committerBen Sima <ben@bsima.me>2025-11-09 08:17:45 -0500
commit6dbb77b5e7525d0b38434267ca97fdbe16b8ef84 (patch)
tree9845e8b545cb40030a60abdf9a9e0028b35f15b3 /Omni
parentda3fa44e76e1d6d1ea93cfe9266dd43a996f800c (diff)
Add enhanced filtering to task list command
Implement --status and --namespace filters for task list: New filters: - --status: Filter by open, in-progress, or done - --namespace: Filter by namespace (e.g., Omni/Task) All filters can be combined: - task list --parent=t-abc123 --status=open - task list --type=epic --status=done - task list --namespace="Omni/Task" --status=open Updated listTasks signature to accept all filter parameters and apply them in sequence. Updated AGENTS.md with examples. Closes task t-PpZGVf
Diffstat (limited to 'Omni')
-rw-r--r--Omni/Task.hs19
-rw-r--r--Omni/Task/Core.hs13
2 files changed, 25 insertions, 7 deletions
diff --git a/Omni/Task.hs b/Omni/Task.hs
index f10ae25..ae854a7 100644
--- a/Omni/Task.hs
+++ b/Omni/Task.hs
@@ -35,7 +35,7 @@ task
Usage:
task init
task create <title> [--type=<type>] [--parent=<id>] [--deps=<ids>] [--dep-type=<type>] [--discovered-from=<id>] [--namespace=<ns>]
- task list [--type=<type>] [--parent=<id>]
+ task list [--type=<type>] [--parent=<id>] [--status=<status>] [--namespace=<ns>]
task ready
task update <id> <status>
task deps <id>
@@ -59,6 +59,7 @@ Options:
-h --help Show this help
--type=<type> Task type: epic or task (default: task)
--parent=<id> Parent epic ID
+ --status=<status> Filter by status: open, in-progress, done
--deps=<ids> Comma-separated list of dependency IDs
--dep-type=<type> Dependency type: blocks, discovered-from, parent-child, related (default: blocks)
--discovered-from=<id> Shortcut for --deps=<id> --dep-type=discovered-from
@@ -124,7 +125,19 @@ move args
maybeParent <- case Cli.getArg args (Cli.longOption "parent") of
Nothing -> pure Nothing
Just p -> pure <| Just (T.pack p)
- tasks <- listTasks maybeType maybeParent
+ maybeStatus <- case Cli.getArg args (Cli.longOption "status") of
+ Nothing -> pure Nothing
+ Just "open" -> pure <| Just Open
+ Just "in-progress" -> pure <| Just InProgress
+ Just "done" -> pure <| Just Done
+ Just other -> panic <| "Invalid status: " <> T.pack other <> ". Use: open, in-progress, or done"
+ maybeNamespace <- case Cli.getArg args (Cli.longOption "namespace") of
+ Nothing -> pure Nothing
+ Just ns -> do
+ let validNs = Namespace.fromHaskellModule ns
+ nsPath = T.pack <| Namespace.toPath validNs
+ pure <| Just nsPath
+ tasks <- listTasks maybeType maybeParent maybeStatus maybeNamespace
traverse_ printTask tasks
| args `Cli.has` Cli.command "ready" = do
tasks <- getReadyTasks
@@ -184,7 +197,7 @@ unitTests =
null (taskDependencies task) Test.@?= True,
Test.unit "can list tasks" <| do
_ <- createTask "Test task for list" WorkTask Nothing Nothing []
- tasks <- listTasks Nothing Nothing
+ tasks <- listTasks Nothing Nothing Nothing Nothing
not (null tasks) Test.@?= True,
Test.unit "ready tasks exclude blocked ones" <| do
task1 <- createTask "First task" WorkTask Nothing Nothing []
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs
index 6285ef7..140d7dc 100644
--- a/Omni/Task/Core.hs
+++ b/Omni/Task/Core.hs
@@ -5,7 +5,6 @@
module Omni.Task.Core where
import Alpha
-import Control.Monad ((>>=))
import Data.Aeson (FromJSON, ToJSON, decode, encode)
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.KeyMap as KM
@@ -210,20 +209,26 @@ updateTaskStatus tid newStatus = do
TIO.writeFile tasksFile ""
traverse_ saveTask updatedTasks
--- List tasks, optionally filtered by type or parent
-listTasks :: Maybe TaskType -> Maybe Text -> IO [Task]
-listTasks maybeType maybeParent = do
+-- List tasks, optionally filtered by type, parent, status, or namespace
+listTasks :: Maybe TaskType -> Maybe Text -> Maybe Status -> Maybe Text -> IO [Task]
+listTasks maybeType maybeParent maybeStatus maybeNamespace = do
tasks <- loadTasks
let filtered =
tasks
|> filterByType maybeType
|> filterByParent maybeParent
+ |> filterByStatus maybeStatus
+ |> filterByNamespace maybeNamespace
pure filtered
where
filterByType Nothing ts = ts
filterByType (Just typ) ts = filter (\t -> taskType t == typ) ts
filterByParent Nothing ts = ts
filterByParent (Just pid) ts = filter (\t -> taskParent t == Just pid) ts
+ filterByStatus Nothing ts = ts
+ filterByStatus (Just status) ts = filter (\t -> taskStatus t == status) ts
+ filterByNamespace Nothing ts = ts
+ filterByNamespace (Just ns) ts = filter (\t -> taskNamespace t == Just ns) ts
-- Get ready tasks (not blocked by dependencies)
getReadyTasks :: IO [Task]