summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/global.cc22
-rw-r--r--src/report.h11
-rw-r--r--test/baseline/opt-plot-amount-format.test10
-rw-r--r--test/baseline/opt-plot-total-format.test10
4 files changed, 38 insertions, 15 deletions
diff --git a/src/global.cc b/src/global.cc
index 60865284..b0b08930 100644
--- a/src/global.cc
+++ b/src/global.cc
@@ -179,8 +179,6 @@ void global_scope_t::execute_command(strings_list args, bool at_repl)
if (bool(command = look_for_precommand(bound_scope, verb)))
is_precommand = true;
- else if (! bool(command = look_for_command(bound_scope, verb)))
- throw_(std::logic_error, _("Unrecognized command '%1'") << verb);
// If it is not a pre-command, then parse the user's ledger data at this
// time if not done alreday (i.e., if not at a REPL). Then patch up the
@@ -189,7 +187,11 @@ void global_scope_t::execute_command(strings_list args, bool at_repl)
if (! is_precommand) {
if (! at_repl)
session().read_journal_files();
+
normalize_report_options(verb);
+
+ if (! bool(command = look_for_command(bound_scope, verb)))
+ throw_(std::logic_error, _("Unrecognized command '%1'") << verb);
}
// Create the output stream (it might be a file, the console or a PAGER
@@ -207,9 +209,8 @@ void global_scope_t::execute_command(strings_list args, bool at_repl)
// Now that the output stream is initialized, report the options that will
// participate in this report, if the user specified --options
- if (HANDLED(options)) {
+ if (HANDLED(options))
report_options(report(), report().output_stream);
- }
// Create an argument scope containing the report command's arguments, and
// then invoke the command. The bound scope causes lookups to happen
@@ -465,18 +466,27 @@ void global_scope_t::normalize_report_options(const string& verb)
if (! rep.HANDLED(begin_) && interval.start) {
string predicate =
"date>=[" + to_iso_extended_string(*interval.start) + "]";
- rep.HANDLER(limit_).on(string("--begin"), predicate);
+ rep.HANDLER(limit_).on(string("?normalize"), predicate);
}
if (! rep.HANDLED(end_) && interval.end) {
string predicate =
"date<[" + to_iso_extended_string(*interval.end) + "]";
- rep.HANDLER(limit_).on(string("--end"), predicate);
+ rep.HANDLER(limit_).on(string("?normalize"), predicate);
}
if (! interval.duration)
rep.HANDLER(period_).off();
}
+ if (rep.HANDLED(amount_data)) {
+ rep.HANDLER(format_)
+ .on_with(string("?normalize"), rep.HANDLER(plot_amount_format_).value);
+ }
+ else if (rep.HANDLED(total_data)) {
+ rep.HANDLER(format_)
+ .on_with(string("?normalize"), rep.HANDLER(plot_total_format_).value);
+ }
+
long cols = 0;
if (rep.HANDLED(columns_))
cols = rep.HANDLER(columns_).value.to_long();
diff --git a/src/report.h b/src/report.h
index 21ad157d..dc53cee7 100644
--- a/src/report.h
+++ b/src/report.h
@@ -330,11 +330,7 @@ public:
set_expr(args[0].to_string(), args[1].to_string());
});
- OPTION_(report_t, amount_data, DO() { // -j
- parent->HANDLER(format_)
- .on_with(none, parent->HANDLER(plot_amount_format_).value);
- });
-
+ OPTION(report_t, amount_data);
OPTION(report_t, anon);
OPTION_(report_t, average, DO() { // -A
@@ -750,10 +746,7 @@ public:
set_expr(args[0].to_string(), args[1].to_string());
});
- OPTION_(report_t, total_data, DO() { // -J
- parent->HANDLER(format_).on_with(string("--total-data"),
- parent->HANDLER(plot_total_format_).value);
- });
+ OPTION(report_t, total_data);
OPTION_(report_t, truncate_, DO() {
#if 0
diff --git a/test/baseline/opt-plot-amount-format.test b/test/baseline/opt-plot-amount-format.test
new file mode 100644
index 00000000..9c5484af
--- /dev/null
+++ b/test/baseline/opt-plot-amount-format.test
@@ -0,0 +1,10 @@
+reg -j --plot-amount-format='X %(format_date(date, "%Y-%m-%d")) Y %(quantity(scrub(display_amount)))\n'
+<<<
+2007/02/02 RD VMMXX
+ Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00
+ Income:Dividends:Vanguard:VMMXX $-0.35
+>>>1
+X 2007-02-02 Y 0.35
+X 2007-02-02 Y -0.35
+>>>2
+=== 0
diff --git a/test/baseline/opt-plot-total-format.test b/test/baseline/opt-plot-total-format.test
new file mode 100644
index 00000000..1065c5ce
--- /dev/null
+++ b/test/baseline/opt-plot-total-format.test
@@ -0,0 +1,10 @@
+reg -J --plot-total-format='X %(format_date(date, "%Y-%m-%d")) Y %(quantity(scrub(display_amount)))\n'
+<<<
+2007/02/02 RD VMMXX
+ Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00
+ Income:Dividends:Vanguard:VMMXX $-0.35
+>>>1
+X 2007-02-02 Y 0.35
+X 2007-02-02 Y -0.35
+>>>2
+=== 0