mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-19 10:17:35 +03:00
imp: accounts: --declarations shows that info, not --debug (#1909)
This commit is contained in:
parent
1f08a8a94e
commit
8ec31b079c
@ -36,6 +36,7 @@ accountsmode = hledgerCommandMode
|
|||||||
([flagNone ["declared"] (setboolopt "declared") "show account names declared with account directives"
|
([flagNone ["declared"] (setboolopt "declared") "show account names declared with account directives"
|
||||||
,flagNone ["used"] (setboolopt "used") "show account names referenced by transactions"
|
,flagNone ["used"] (setboolopt "used") "show account names referenced by transactions"
|
||||||
,flagNone ["types"] (setboolopt "types") "also show accounts' types, when known"
|
,flagNone ["types"] (setboolopt "types") "also show accounts' types, when known"
|
||||||
|
,flagNone ["declarations"] (setboolopt "declarations") "also show where accounts were declared, for troubleshooting"
|
||||||
]
|
]
|
||||||
++ flattreeflags False ++
|
++ flattreeflags False ++
|
||||||
[flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"
|
[flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"
|
||||||
@ -53,6 +54,7 @@ accounts CliOpts{rawopts_=rawopts, reportspec_=ReportSpec{_rsQuery=query,_rsRepo
|
|||||||
declared = boolopt "declared" rawopts
|
declared = boolopt "declared" rawopts
|
||||||
used = boolopt "used" rawopts
|
used = boolopt "used" rawopts
|
||||||
types = boolopt "types" rawopts
|
types = boolopt "types" rawopts
|
||||||
|
declarations = boolopt "declarations" rawopts
|
||||||
-- a depth limit will clip and exclude account names later, but we don't want to exclude accounts at this stage
|
-- a depth limit will clip and exclude account names later, but we don't want to exclude accounts at this stage
|
||||||
nodepthq = dbg4 "nodepthq" $ filterQuery (not . queryIsDepth) query
|
nodepthq = dbg4 "nodepthq" $ filterQuery (not . queryIsDepth) query
|
||||||
-- just the acct: part of the query will be reapplied later, after clipping
|
-- just the acct: part of the query will be reapplied later, after clipping
|
||||||
@ -94,17 +96,16 @@ accounts CliOpts{rawopts_=rawopts, reportspec_=ReportSpec{_rsQuery=query,_rsRepo
|
|||||||
showType a
|
showType a
|
||||||
| types = pad a <> " ; type: " <> maybe "" (T.pack . show) (journalAccountType j a)
|
| types = pad a <> " ; type: " <> maybe "" (T.pack . show) (journalAccountType j a)
|
||||||
| otherwise = ""
|
| otherwise = ""
|
||||||
-- for troubleshooting account display order
|
showAcctDeclOrder a
|
||||||
dbgAcctDeclOrder a
|
| declarations =
|
||||||
| debugLevel >= 2 =
|
|
||||||
(if types then "," else pad a <> " ;") <>
|
(if types then "," else pad a <> " ;") <>
|
||||||
case lookup a $ jdeclaredaccounts j of
|
case lookup a $ jdeclaredaccounts j of
|
||||||
Just adi ->
|
Just adi ->
|
||||||
" declared at " <> (T.pack $ sourcePosPretty $ adisourcepos adi) <>
|
" declared at " <> (T.pack $ sourcePosPretty $ adisourcepos adi) <> -- TODO: hide the column number
|
||||||
", overall declaration order " <> (T.pack $ show $ adideclarationorder adi)
|
", overall declaration order " <> (T.pack $ show $ adideclarationorder adi)
|
||||||
Nothing -> " undeclared"
|
Nothing -> " undeclared"
|
||||||
| otherwise = ""
|
| otherwise = ""
|
||||||
pad a = T.replicate (maxwidth - T.length (showName a)) " "
|
pad a = T.replicate (maxwidth - T.length (showName a)) " "
|
||||||
maxwidth = maximum $ map (T.length . showName) clippedaccts
|
maxwidth = maximum $ map (T.length . showName) clippedaccts
|
||||||
|
|
||||||
forM_ clippedaccts $ \a -> T.putStrLn $ showName a <> showType a <> dbgAcctDeclOrder a
|
forM_ clippedaccts $ \a -> T.putStrLn $ showName a <> showType a <> showAcctDeclOrder a
|
||||||
|
@ -15,6 +15,10 @@ Account names can be depth-clipped with `depth:N` or `--depth N` or `-N`.
|
|||||||
With `--types`, it also shows each account's type, if it's known.
|
With `--types`, it also shows each account's type, if it's known.
|
||||||
(See Declaring accounts > Account types.)
|
(See Declaring accounts > Account types.)
|
||||||
|
|
||||||
|
With `--declarations`, it also shows the file and line number of each
|
||||||
|
account's declaration, if any, and the account's overall declaration order;
|
||||||
|
these may be useful when troubleshooting account display order.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
Loading…
Reference in New Issue
Block a user