summaryrefslogtreecommitdiff
path: root/src/report.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-27 03:58:43 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-27 03:58:43 -0400
commit6b62be59fbb8a0b8fd4274fa46ca7295f1be0919 (patch)
treea14d7a1c3962d901cc26510fbb124380c0181a56 /src/report.cc
parent645e43ef75b1af78ef6a4013684d76fd7d6e7118 (diff)
downloadfork-ledger-6b62be59fbb8a0b8fd4274fa46ca7295f1be0919.tar.gz
fork-ledger-6b62be59fbb8a0b8fd4274fa46ca7295f1be0919.tar.bz2
fork-ledger-6b62be59fbb8a0b8fd4274fa46ca7295f1be0919.zip
Added generate command, --seed, and GenerateTests
Diffstat (limited to 'src/report.cc')
-rw-r--r--src/report.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/report.cc b/src/report.cc
index a969a2b8..5e4ba48d 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -32,6 +32,7 @@
#include "report.h"
#include "interactive.h"
#include "iterators.h"
+#include "generate.h"
#include "filters.h"
#include "chain.h"
#include "output.h"
@@ -48,6 +49,14 @@ void report_t::posts_report(post_handler_ptr handler)
session.clean_posts();
}
+void report_t::generate_report(post_handler_ptr handler)
+{
+ generate_posts_iterator walker
+ (session, HANDLED(seed_) ?
+ static_cast<unsigned int>(HANDLER(seed_).value.to_long()) : 0);
+ pass_down_posts(chain_post_handlers(*this, handler), walker);
+}
+
void report_t::xact_report(post_handler_ptr handler, xact_t& xact)
{
xact_posts_iterator walker(xact);
@@ -536,6 +545,7 @@ option_t<report_t> * report_t::lookup_option(const char * p)
else OPT(sort_xacts_);
else OPT_(subtotal);
else OPT(start_of_week_);
+ else OPT(seed_);
break;
case 't':
OPT_CH(amount_);
@@ -709,6 +719,12 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
if (is_eq(q, "format"))
return WRAP_FUNCTOR(format_command);
break;
+ case 'g':
+ if (is_eq(q, "generate"))
+ return expr_t::op_t::wrap_functor
+ (reporter<post_t, post_handler_ptr, &report_t::generate_report>
+ (new format_posts(*this, report_format(HANDLER(print_format_)),
+ false), *this));
case 'h':
if (is_eq(q, "hello") && maybe_import("ledger.hello"))
return session.lookup(string(PRECMD_PREFIX) + "hello");