Added a "show" report query term

Everything beyond the show modifies the --display predicate, and
everything before modifies the --limit predicate.
This commit is contained in:
John Wiegley 2009-03-02 22:33:43 -04:00
parent 31d6430c78
commit 710e4792d1
4 changed files with 45 additions and 10 deletions

View file

@ -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

View file

@ -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;;

View file

@ -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

View file

@ -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));