It's OK for a report query to be empty

It's always possible the user only specified a display predicate.
This commit is contained in:
John Wiegley 2009-11-18 23:15:22 -05:00
parent 93b8f3fe54
commit e27ba3e1ff
2 changed files with 20 additions and 28 deletions

View file

@ -184,14 +184,12 @@ value_t args_command(call_scope_t& args)
out << std::endl << std::endl; out << std::endl << std::endl;
query_t query(args.value(), report.what_to_keep()); query_t query(args.value(), report.what_to_keep());
if (! query) if (query) {
throw_(std::runtime_error,
_("Invalid query predicate: %1") << join_args(args));
call_scope_t sub_args(static_cast<scope_t&>(args)); call_scope_t sub_args(static_cast<scope_t&>(args));
sub_args.push_back(string_value(query.text())); sub_args.push_back(string_value(query.text()));
parse_command(sub_args); parse_command(sub_args);
}
if (query.tokens_remaining()) { if (query.tokens_remaining()) {
out << std::endl << _("====== Display predicate ======") out << std::endl << _("====== Display predicate ======")
@ -199,15 +197,13 @@ value_t args_command(call_scope_t& args)
query.parse_again(); query.parse_again();
if (! query) if (query) {
throw_(std::runtime_error,
_("Invalid display predicate: %1") << join_args(args));
call_scope_t disp_sub_args(static_cast<scope_t&>(args)); call_scope_t disp_sub_args(static_cast<scope_t&>(args));
disp_sub_args.push_back(string_value(query.text())); disp_sub_args.push_back(string_value(query.text()));
parse_command(disp_sub_args); parse_command(disp_sub_args);
} }
}
return NULL_VALUE; return NULL_VALUE;
} }

View file

@ -222,27 +222,23 @@ void report_t::normalize_options(const string& verb)
void report_t::parse_query_args(const value_t& args, const string& whence) void report_t::parse_query_args(const value_t& args, const string& whence)
{ {
query_t query(args, what_to_keep()); query_t query(args, what_to_keep());
if (! query) if (query) {
throw_(std::runtime_error,
_("Invalid query predicate: %1") << query.text());
HANDLER(limit_).on(whence, query.text()); HANDLER(limit_).on(whence, query.text());
DEBUG("report.predicate", DEBUG("report.predicate",
"Predicate = " << HANDLER(limit_).str()); "Predicate = " << HANDLER(limit_).str());
}
if (query.tokens_remaining()) { if (query.tokens_remaining()) {
query.parse_again(); query.parse_again();
if (! query) if (query) {
throw_(std::runtime_error,
_("Invalid display predicate: %1") << query.text());
HANDLER(display_).on(whence, query.text()); HANDLER(display_).on(whence, query.text());
DEBUG("report.predicate", DEBUG("report.predicate",
"Display predicate = " << HANDLER(display_).str()); "Display predicate = " << HANDLER(display_).str());
} }
} }
}
void report_t::posts_report(post_handler_ptr handler) void report_t::posts_report(post_handler_ptr handler)
{ {