summaryrefslogtreecommitdiff
path: root/Omni
diff options
context:
space:
mode:
Diffstat (limited to 'Omni')
-rw-r--r--Omni/Task.hs7
-rw-r--r--Omni/Task/Core.hs39
2 files changed, 46 insertions, 0 deletions
diff --git a/Omni/Task.hs b/Omni/Task.hs
index 0aca674..ef912f9 100644
--- a/Omni/Task.hs
+++ b/Omni/Task.hs
@@ -39,6 +39,7 @@ Usage:
task ready
task update <id> <status>
task deps <id>
+ task tree [<id>]
task export [--flush]
task import -i <file>
task test
@@ -51,6 +52,7 @@ Commands:
ready Show ready tasks (not blocked)
update Update task status
deps Show dependency tree
+ tree Show task tree (epics with children, or all epics if no ID given)
export Export and consolidate tasks to JSONL
import Import tasks from JSONL file
test Run tests
@@ -158,6 +160,11 @@ move args
| args `Cli.has` Cli.command "deps" = do
tid <- getArgText args "id"
showDependencyTree tid
+ | args `Cli.has` Cli.command "tree" = do
+ maybeId <- case Cli.getArg args (Cli.argument "id") of
+ Nothing -> pure Nothing
+ Just idStr -> pure <| Just (T.pack idStr)
+ showTaskTree maybeId
| args `Cli.has` Cli.command "export" = do
exportTasks
putText "Exported and consolidated tasks to .tasks/tasks.jsonl"
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs
index 140d7dc..1a9cb2e 100644
--- a/Omni/Task/Core.hs
+++ b/Omni/Task/Core.hs
@@ -256,6 +256,45 @@ showDependencyTree tid = do
deps = filter (\t -> taskId t `elem` depIds) allTasks
traverse_ (\dep -> printTree allTasks dep (indent + 1)) deps
+-- Show task tree (epic with children, or all epics if no ID given)
+showTaskTree :: Maybe Text -> IO ()
+showTaskTree maybeId = do
+ tasks <- loadTasks
+ case maybeId of
+ Nothing -> do
+ -- Show all epics with their children
+ let epics = filter (\t -> taskType t == Epic) tasks
+ if null epics
+ then putText "No epics found"
+ else traverse_ (printEpicTree tasks) epics
+ Just tid -> do
+ -- Show specific task/epic with its children
+ case filter (\t -> taskId t == tid) tasks of
+ [] -> putText "Task not found"
+ (task : _) -> printEpicTree tasks task
+ where
+ printEpicTree :: [Task] -> Task -> IO ()
+ printEpicTree allTasks task = printTreeNode allTasks task 0
+
+ printTreeNode :: [Task] -> Task -> Int -> IO ()
+ printTreeNode allTasks task indent = do
+ let prefix = T.pack (replicate (indent * 2) ' ')
+ typeStr = case taskType task of
+ Epic -> "[Epic]"
+ WorkTask -> "[Task]"
+ statusStr = case taskStatus task of
+ Open -> "[ ]"
+ InProgress -> "[~]"
+ Done -> "[✓]"
+ nsStr = case taskNamespace task of
+ Nothing -> ""
+ Just ns -> " [" <> ns <> "]"
+ putText <| prefix <> taskId task <> " " <> typeStr <> " " <> statusStr <> " " <> taskTitle task <> nsStr
+
+ -- Find and print children (tasks with this task as parent)
+ let children = filter (\t -> taskParent t == Just (taskId task)) allTasks
+ traverse_ (\child -> printTreeNode allTasks child (indent + 1)) children
+
-- Helper to print a task
printTask :: Task -> IO ()
printTask t =