diff options
author | John Wiegley <johnw@newartisans.com> | 2009-03-02 22:33:43 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-03-02 22:33:43 -0400 |
commit | 710e4792d12bcc073e4396de8930f27dc516ef3e (patch) | |
tree | d634349e1d16f9bfd6bf77bb6c55dfdbdc5345b9 /src | |
parent | 31d6430c78abce55b40e64be0b99c7ea7f76df44 (diff) | |
download | fork-ledger-710e4792d12bcc073e4396de8930f27dc516ef3e.tar.gz fork-ledger-710e4792d12bcc073e4396de8930f27dc516ef3e.tar.bz2 fork-ledger-710e4792d12bcc073e4396de8930f27dc516ef3e.zip |
Added a "show" report query term
Everything beyond the show modifies the --display predicate, and
everything before modifies the --limit predicate.
Diffstat (limited to 'src')
-rw-r--r-- | src/precmd.cc | 23 | ||||
-rw-r--r-- | src/predicate.cc | 7 | ||||
-rw-r--r-- | src/predicate.h | 2 | ||||
-rw-r--r-- | src/report.cc | 23 |
4 files changed, 45 insertions, 10 deletions
diff --git a/src/precmd.cc b/src/precmd.cc index ef2b66dc..e04470b8 100644 --- a/src/precmd.cc +++ b/src/precmd.cc @@ -99,7 +99,7 @@ value_t parse_command(call_scope_t& args) result.strip_annotations(report.what_to_keep()).dump(out); out << std::endl; - return 0L; + return NULL_VALUE; } value_t eval_command(call_scope_t& args) @@ -111,7 +111,7 @@ value_t eval_command(call_scope_t& args) if (! result.is_null()) report.output_stream << result << std::endl; - return 0L; + return NULL_VALUE; } value_t format_command(call_scope_t& args) @@ -140,7 +140,7 @@ value_t format_command(call_scope_t& args) fmt.format(out, bound_scope); out << "\"\n"; - return 0L; + return NULL_VALUE; } value_t period_command(call_scope_t& args) @@ -176,7 +176,7 @@ value_t period_command(call_scope_t& args) break; } } - return 0L; + return NULL_VALUE; } value_t args_command(call_scope_t& args) @@ -196,7 +196,20 @@ value_t args_command(call_scope_t& args) call_scope_t sub_args(static_cast<scope_t&>(args)); sub_args.push_back(string_value(predicate)); - return parse_command(sub_args); + parse_command(sub_args); + + if (begin != end) { + out << std::endl << _("====== Display predicate ======") + << std::endl << std::endl; + + predicate = args_to_predicate_expr(begin, end); + + call_scope_t disp_sub_args(static_cast<scope_t&>(args)); + disp_sub_args.push_back(string_value(predicate)); + + parse_command(disp_sub_args); + } + return NULL_VALUE; } } // namespace ledger diff --git a/src/predicate.cc b/src/predicate.cc index 3402ca3b..2ff897e5 100644 --- a/src/predicate.cc +++ b/src/predicate.cc @@ -33,7 +33,7 @@ namespace ledger { -string args_to_predicate_expr(value_t::sequence_t::const_iterator begin, +string args_to_predicate_expr(value_t::sequence_t::const_iterator& begin, value_t::sequence_t::const_iterator end) { std::ostringstream expr; @@ -44,6 +44,11 @@ string args_to_predicate_expr(value_t::sequence_t::const_iterator begin, string arg = (*begin).as_string(); string prefix; + if (arg == "show") { + ++begin; + break; + } + bool parse_argument = true; bool only_closed_parenthesis = false;; diff --git a/src/predicate.h b/src/predicate.h index c3773c43..9eafa95a 100644 --- a/src/predicate.h +++ b/src/predicate.h @@ -95,7 +95,7 @@ public: } }; -string args_to_predicate_expr(value_t::sequence_t::const_iterator begin, +string args_to_predicate_expr(value_t::sequence_t::const_iterator& begin, value_t::sequence_t::const_iterator end); } // namespace ledger diff --git a/src/report.cc b/src/report.cc index 0b3d625a..6a311bb8 100644 --- a/src/report.cc +++ b/src/report.cc @@ -322,11 +322,28 @@ namespace { value_t operator()(call_scope_t& args) { if (args.size() > 0) { - report.HANDLER(limit_).on - (args_to_predicate_expr(args.value().as_sequence().begin(), - args.value().as_sequence().end())); + value_t::sequence_t::const_iterator begin = + args.value().as_sequence().begin(); + value_t::sequence_t::const_iterator end = + args.value().as_sequence().end(); + + string limit = args_to_predicate_expr(begin, end); + + if (! limit.empty()) + report.HANDLER(limit_).on(limit); + DEBUG("report.predicate", "Predicate = " << report.HANDLER(limit_).str()); + + string display; + if (begin != end) + display = args_to_predicate_expr(begin, end); + + if (! display.empty()) + report.HANDLER(display_).on(display); + + DEBUG("report.predicate", + "Display predicate = " << report.HANDLER(display_).str()); } (report.*report_method)(handler_ptr(handler)); |