How to force overwrite the options in the .ledgerc init file

13 views
Skip to first unread message

Felipe Mica

unread,
Sep 11, 2021, 9:12:47 PMSep 11
to Ledger
I put this in my .ledgerc file:
--depth 4

Now, if I do:

ledger --depth 1 balance

the ledger overwrites the option in the init file and shows only 1 depth. That's the expected behavior. However, if put some depth bigger than the defined 4 in the file, I would get only 4 levels. The option defined in the init file is used as "maximum" depth value, which makes no sense to me.

Am I missing something?


Thank you.

Rahix

unread,
Sep 12, 2021, 3:07:41 AMSep 12
to ledge...@googlegroups.com
Hi,
I think what's happening here is that both --depth options get applied,
one after the other. The following command behaves exactly the same:

ledger bal --depth 4 --depth 1

The reason for this is closely tied to the way these "filters" are
applied in ledger, so I think it isn't that easy to change this without
introducing inconsistencies...

However maybe open a bug on GH to discuss whether this should be changed
in the future? I do see the appeal of having later --depth options
overwrite any earlier ones, it does feel more sensible to me as well...

--
Rahix

Felipe Mica

unread,
Sep 13, 2021, 11:52:26 AMSep 13
to Ledger
Why

ledger bal --depth 4 --depth 1

Makes 1 overwrite 4, but:

ledger bal --depth 4 --depth 6

6 doesn't overwrite 4?

Is it a reason for that or it is a bug? It's a weird behavior for me.

Rahix

unread,
Sep 13, 2021, 11:55:40 AMSep 13
to ledge...@googlegroups.com
On Mon, 2021-09-13 at 08:52 -0700, Felipe Mica wrote:
> Why
>
> ledger bal --depth 4 --depth 1
>
> Makes 1 overwrite 4, but:
>
> ledger bal --depth 4 --depth 6
>
> 6 doesn't overwrite 4?
>
> Is it a reason for that or it is a bug? It's a weird behavior for me.

Leaving out whether or not this behavior makes sense, what's happening
here is as follows:

The commandline options are processed in series and each "filter" gets
applied one after the other. The reason `--depth 6` doesn't "overwrite"
`--depth 4` is that after applying `--depth 4`, only accounts with up to
4 levels are still in the list so the `--depth 6` filter does not even
see any of the deeper-level accounts anymore.

Felipe Mica

unread,
Sep 13, 2021, 12:02:34 PMSep 13
to Ledger
Ah! I see. So it's a restrictive filter. That's why always the more restrict filter will prevail. 6 wider than 4. So, how can I solve this in my case? I want to use depth 4 as default but sometimes I want to be able to define 6. Can you imagine a hack for that?

Thank you.
Reply all
Reply to author
Forward
0 new messages