diff options
author | John Wiegley <johnw@newartisans.com> | 2006-02-15 09:51:50 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:21 -0400 |
commit | 85b81a762bc396d40976f9cfdf089fdc6dcbf3d8 (patch) | |
tree | cd72d44bad739988c7300da508c5d50b64ea67a4 | |
parent | fd8957368d3406e0af3c75065ed10ed9df2b0ae5 (diff) | |
download | fork-ledger-85b81a762bc396d40976f9cfdf089fdc6dcbf3d8.tar.gz fork-ledger-85b81a762bc396d40976f9cfdf089fdc6dcbf3d8.tar.bz2 fork-ledger-85b81a762bc396d40976f9cfdf089fdc6dcbf3d8.zip |
Added support for outputting to CSV format.
-rw-r--r-- | config.cc | 8 | ||||
-rw-r--r-- | config.h | 1 | ||||
-rw-r--r-- | main.cc | 4 |
3 files changed, 12 insertions, 1 deletions
@@ -36,6 +36,7 @@ void config_t::reset() "%32|%-.22A %12.67t %12.80T\n"); wide_register_format = ("%D %-.35P %-.38A %22.108t %22.132T\n%/" "%48|%-.38A %22.108t %22.132T\n"); + csv_register_format = "\"%D\",\"%P\",\"%A\",\"%t\",\"%T\"\n"; plot_amount_format = "%D %(St)\n"; plot_total_format = "%D %(ST)\n"; print_format = "\n%d %Y%C%P\n %-34W %12o%n\n%/ %-34W %12o%n\n"; @@ -512,7 +513,7 @@ Output customization:\n\ -F, --format STR use STR as the format; for each report type, use:\n\ --balance-format --register-format --print-format\n\ --plot-amount-format --plot-total-format --equity-format\n\ - --prices-format --wide-register-format\n\ + --prices-format --wide-register-format\n\n\ Commodity reporting:\n\ --price-db FILE sets the price database to FILE (def: ~/.pricedb)\n\ -L, --price-exp MINS download quotes only if newer than MINS (def: 1440)\n\ @@ -814,6 +815,10 @@ OPT_BEGIN(wide_register_format, ":") { config->wide_register_format = optarg; } OPT_END(wide_register_format); +OPT_BEGIN(csv_register_format, ":") { + config->csv_register_format = optarg; +} OPT_END(csv_register_format); + OPT_BEGIN(plot_amount_format, ":") { config->plot_amount_format = optarg; } OPT_END(plot_amount_format); @@ -1138,6 +1143,7 @@ void export_config() .def_readwrite("balance_format", &config_t::balance_format) .def_readwrite("register_format", &config_t::register_format) .def_readwrite("wide_register_format", &config_t::wide_register_format) + .def_readwrite("csv_register_format", &config_t::csv_register_format) .def_readwrite("plot_amount_format", &config_t::plot_amount_format) .def_readwrite("plot_total_format", &config_t::plot_total_format) .def_readwrite("print_format", &config_t::print_format) @@ -29,6 +29,7 @@ class config_t std::string balance_format; std::string register_format; std::string wide_register_format; + std::string csv_register_format; std::string plot_amount_format; std::string plot_total_format; std::string print_format; @@ -118,6 +118,10 @@ int parse_and_report(int argc, char * argv[], char * envp[]) command = "P"; else if (command == "pricesdb") command = "D"; + else if (command == "csv") { + config.register_format = config.csv_register_format; + command = "r"; + } else throw error(std::string("Unrecognized command '") + command + "'"); |