summaryrefslogtreecommitdiff
path: root/Omni/Task/Core.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Omni/Task/Core.hs')
-rw-r--r--Omni/Task/Core.hs28
1 files changed, 23 insertions, 5 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs
index 1dc31a8..f463040 100644
--- a/Omni/Task/Core.hs
+++ b/Omni/Task/Core.hs
@@ -10,6 +10,7 @@ import qualified Data.Aeson as Aeson
import qualified Data.Aeson.KeyMap as KM
import Data.Aeson.Types (parseMaybe)
import qualified Data.ByteString.Lazy.Char8 as BLC
+import qualified Data.List as List
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import Data.Time (UTCTime, diffTimeToPicoseconds, getCurrentTime, utctDayTime)
@@ -324,9 +325,19 @@ showTaskTree maybeId = do
printEpicTree allTasks task = printTreeNode allTasks task 0
printTreeNode :: [Task] -> Task -> Int -> IO ()
- printTreeNode allTasks task indent = do
- let prefix = T.pack (replicate (indent * 2) ' ')
- children = filter (\t -> taskParent t == Just (taskId task)) allTasks
+ printTreeNode allTasks task indent = printTreeNode' allTasks task indent []
+
+ printTreeNode' :: [Task] -> Task -> Int -> [Bool] -> IO ()
+ printTreeNode' allTasks task indent ancestry = do
+ let children = filter (\t -> taskParent t == Just (taskId task)) allTasks
+ -- Build tree prefix using box-drawing characters
+ prefix =
+ if indent == 0
+ then ""
+ else
+ let ancestorPrefixes = map (\hasMore -> if hasMore then "│ " else " ") (List.init ancestry)
+ myPrefix = if List.last ancestry then "├── " else "└── "
+ in T.pack <| concat ancestorPrefixes ++ myPrefix
-- For epics, show progress count [completed/total]; for tasks, show status checkbox
statusStr = case taskType task of
Epic ->
@@ -349,8 +360,15 @@ showTaskTree maybeId = do
else taskTitle task
putText <| prefix <> taskId task <> " " <> statusStr <> " " <> nsStr <> truncatedTitle
- -- Print children
- traverse_ (\child -> printTreeNode allTasks child (indent + 1)) children
+ -- Print children with updated ancestry
+ let indexedChildren = zip [1 ..] children
+ totalChildren = length children
+ traverse_
+ ( \(idx, child) ->
+ let hasMoreSiblings = idx < totalChildren
+ in printTreeNode' allTasks child (indent + 1) (ancestry ++ [hasMoreSiblings])
+ )
+ indexedChildren
-- Helper to print a task
printTask :: Task -> IO ()