From 035f2ac4bbd500e5564b4a90f5dafaefb6c0f5bf Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 7 Aug 2022 10:48:55 +0100 Subject: [PATCH] imp: accounts: at --debug 2, show account declaration positions (#1909) --- hledger/Hledger/Cli/Commands/Accounts.hs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hledger/Hledger/Cli/Commands/Accounts.hs b/hledger/Hledger/Cli/Commands/Accounts.hs index fdf233a3e..19719ce4b 100644 --- a/hledger/Hledger/Cli/Commands/Accounts.hs +++ b/hledger/Hledger/Cli/Commands/Accounts.hs @@ -92,9 +92,19 @@ accounts CliOpts{rawopts_=rawopts, reportspec_=ReportSpec{_rsQuery=query,_rsRepo indent = T.replicate (2 * (max 0 (accountNameLevel a - drop_ ropts) - 1)) " " droppedName = accountNameDrop (drop_ ropts) a showType a - | types = spacer <> " ; type: " <> maybe "" (T.pack . show) (journalAccountType j a) + | types = pad a <> " ; type: " <> maybe "" (T.pack . show) (journalAccountType j a) | otherwise = "" - where - spacer = T.replicate (maxwidth - T.length (showName a)) " " + -- for troubleshooting account display order + dbgAcctDeclOrder a + | debugLevel >= 2 = + (if types then "," else pad a <> " ;") <> + case lookup a $ jdeclaredaccounts j of + Just adi -> + " declared at " <> (T.pack $ sourcePosPretty $ adisourcepos adi) <> + ", overall declaration order " <> (T.pack $ show $ adideclarationorder adi) + Nothing -> " undeclared" + | otherwise = "" + pad a = T.replicate (maxwidth - T.length (showName a)) " " maxwidth = maximum $ map (T.length . showName) clippedaccts - forM_ clippedaccts $ \a -> T.putStrLn $ showName a <> showType a + + forM_ clippedaccts $ \a -> T.putStrLn $ showName a <> showType a <> dbgAcctDeclOrder a