You are correct, of course. I attempted that approach but decided moving the init-file logic to the handle_debug_options was much simpler, even if not as obvious from the names of the functions. Identifying the source of the init-file specification was the key to eliminating the bug and I really can't see anyway to do it other than using 'on()' (it appears to be the only place that function is used based on grepping around the code). A similar approach is needed for the price-db and get-quotes (if it ever comes back)...
On Tue, Jan 8, 2013 at 11:04 AM, Johann Klähn <[email protected]> wrote: > The problem with 'init-file' though is that `read_init()` is called in > the constructor of `global_scope_t` and the arguments are read later > through a call to `global_scope->read_command_arguments()` in > `main()`. > Your patch introduced logic for init-file in `handle_debug_options()`. > A cleaner way would be to set `init-file` using the option handling > code in that constructor but one would have to introduce a further > loop to extract the init-file argument before `read_init()` is called. > Take a look at `global_scope_t::read_environment_settings()` for how > to set an option using the option handling code. > Maybe the option definition for `init-file` in `global.h` should check > if the file can not be found and throw an error (using 'DO_')? But as > the constructor also calls 'on()' the original question remains the > same: How to differentiate between default and user-provided value. > > On Tue, Jan 8, 2013 at 6:06 PM, Craig Earls <[email protected]> wrote: > > John, > > Some time ago I submitted a pull request to fix a problem with ledger > and > > the default init file. You mentioned on the comments to the pull request > > that ledger has a way of signaling that an option came from the command > line > > (I added a method to interrogate the data for the options command). I > can't > > figure it out when/where ledger is storing that information. > > > > There is a similar problem with pricedb (Bug705) that I want to work, > and it > > is probably worth solving both the same way. > > > > -- > > Craig, Corona De Tucson, AZ > > enderw88.wordpress.com > -- Craig, Corona De Tucson, AZ enderw88.wordpress.com
