diff options
author | John Wiegley <johnw@newartisans.com> | 2008-08-14 04:14:48 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-08-14 04:14:48 -0400 |
commit | 6432d7c594023fa5a4fbc9072c28bdd80b670c8a (patch) | |
tree | 56e9b2f88cb3ebf2968bb510c3f82662601d7373 /src/main.cc | |
parent | 2bff7565c1762202c7c01bf7cb50bd9ce351031a (diff) | |
download | fork-ledger-6432d7c594023fa5a4fbc9072c28bdd80b670c8a.tar.gz fork-ledger-6432d7c594023fa5a4fbc9072c28bdd80b670c8a.tar.bz2 fork-ledger-6432d7c594023fa5a4fbc9072c28bdd80b670c8a.zip |
Added back a lot of hacktastic logic from 2.6.1 that made the "bal" command
somewhat smart about how it interpreted certain options. Beware, code, for
your days are not long-lived.
Diffstat (limited to 'src/main.cc')
-rw-r--r-- | src/main.cc | 77 |
1 files changed, 73 insertions, 4 deletions
diff --git a/src/main.cc b/src/main.cc index 8790fb17..ed7b8f2f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -398,18 +398,26 @@ namespace ledger { function_t command; - if (verb == "register" || verb == "reg" || verb == "r") + if (verb == "register" || verb == "reg" || verb == "r") { + verb = "register"; command = reporter<>(new format_xacts(report, session.register_format)); - else if (verb == "print" || verb == "p") + } + else if (verb == "print" || verb == "p") { + verb = "print"; command = reporter<>(new format_xacts(report, session.print_format)); - else if (verb == "balance" || verb == "bal" || verb == "b") + } + else if (verb == "balance" || verb == "bal" || verb == "b") { + verb = "balance"; command = reporter<account_t, acct_handler_ptr, &report_t::accounts_report> (new format_accounts(report, session.balance_format)); - else if (verb == "equity") + } + else if (verb == "equity") { + verb = "equity"; command = reporter<account_t, acct_handler_ptr, &report_t::accounts_report> (new format_equity(report, session.print_format)); + } #if 0 else if (verb == "entry") command = entry_command(); @@ -440,6 +448,67 @@ namespace ledger { throw_(std::logic_error, string("Unrecognized command '") + verb + "'"); } + // Patch up some of the reporting options based on what kind of + // command it was. + + // jww (2008-08-14): This code really needs to be rationalized away + // for 3.0. + + if (verb == "print" || verb == "entry" || verb == "dump") { + report.show_related = true; + report.show_all_related = true; + } + else if (verb == "equity") { + report.show_subtotal = true; + } + else if (report.show_related) { + if (verb == "register") { + report.show_inverted = true; + } else { + report.show_subtotal = true; + report.show_all_related = true; + } + } + + if (verb != "balance" && verb != "register") + amount_t::keep_base = true; + + // Setup the default value for the display predicate + + if (report.display_predicate.empty()) { + if (verb == "balance") { + if (! report.show_empty) + report.display_predicate = "total"; + if (! report.show_subtotal) { + if (! report.display_predicate.empty()) + report.display_predicate += "&"; + report.display_predicate += "depth<=1"; + } + } + else if (verb == "equity") { + report.display_predicate = "fmt_t"; // jww (2008-08-14): ??? + } + else if (verb == "register" && ! report.show_empty) { + report.display_predicate = "amount"; + } + } + + // Now setup the various formatting strings + + // jww (2008-08-14): I hear a song, and it's sound is "HaAaaCcK" + +#if 0 + if (! date_output_format.empty()) + date_t::output_format = date_output_format; +#endif + + amount_t::keep_price = report.keep_price; + amount_t::keep_date = report.keep_date; + amount_t::keep_tag = report.keep_tag; + + if (! report.report_period.empty() && ! report.sort_all) + report.entry_sort = true; + // Create an argument scope containing the report command's // arguments, and then invoke the command. |