summaryrefslogtreecommitdiff
path: root/src/output.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2018-01-27 00:42:39 -0800
committerGitHub <noreply@github.com>2018-01-27 00:42:39 -0800
commitb7b0280066ab36fd8edf5121826780beac391157 (patch)
treef7dbfb382f93124c0754b2c000e2d9f17b333740 /src/output.cc
parent1be23f1653724b4e7a197662bc5418c5996b1136 (diff)
parent6b998aee1023112f27cd2d34d85b189714a944e0 (diff)
downloadfork-ledger-b7b0280066ab36fd8edf5121826780beac391157.tar.gz
fork-ledger-b7b0280066ab36fd8edf5121826780beac391157.tar.bz2
fork-ledger-b7b0280066ab36fd8edf5121826780beac391157.zip
Merge pull request #519 from mbudde/accounts-prepend-format
Add support for --prepend-format in accounts command
Diffstat (limited to 'src/output.cc')
-rw-r--r--src/output.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/output.cc b/src/output.cc
index 94f25eba..c2fa83ac 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -282,8 +282,23 @@ void format_accounts::operator()(account_t& account)
void report_accounts::flush()
{
std::ostream& out(report.output_stream);
+ format_t prepend_format;
+ std::size_t prepend_width;
+
+ if (report.HANDLED(prepend_format_)) {
+ prepend_format.parse_format(report.HANDLER(prepend_format_).str());
+ prepend_width = report.HANDLED(prepend_width_)
+ ? lexical_cast<std::size_t>(report.HANDLER(prepend_width_).str())
+ : 0;
+ }
foreach (accounts_pair& entry, accounts) {
+ if (prepend_format) {
+ bind_scope_t bound_scope(report, *entry.first);
+ out.width(static_cast<std::streamsize>(prepend_width));
+ out << prepend_format(bound_scope);
+ }
+
if (report.HANDLED(count))
out << entry.second << ' ';
out << *entry.first << '\n';