diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-13 03:43:51 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-13 03:45:06 -0500 |
commit | c8dd3d28e3ed39ca93f9aac71a127f15c8d65e4b (patch) | |
tree | 5c9f9c862da2b193971a8f506c4d519ec0831ac3 | |
parent | 2932e05c1841d7154c83ead89f15a664e09ecbf0 (diff) | |
download | fork-ledger-c8dd3d28e3ed39ca93f9aac71a127f15c8d65e4b.tar.gz fork-ledger-c8dd3d28e3ed39ca93f9aac71a127f15c8d65e4b.tar.bz2 fork-ledger-c8dd3d28e3ed39ca93f9aac71a127f15c8d65e4b.zip |
Added --time-report option
This is a rather basic option at the moment which only affects the
balance report. I use it as follows, for entering contractor hours into
a project planning application, where $1 is the contractor's timelog
file, and $2 is the date after which new entries appear in the file:
ledger -f $1 balance \
--account=payee \
--time-report \
-d "latest > [$2]" \
--datetime-format='%m/%d/%y %I:%M %p'
-rw-r--r-- | doc/ledger.1 | 3 | ||||
-rw-r--r-- | src/report.cc | 1 | ||||
-rw-r--r-- | src/report.h | 20 | ||||
-rw-r--r-- | test/baseline/opt-time-report.test | 0 |
4 files changed, 23 insertions, 1 deletions
diff --git a/doc/ledger.1 b/doc/ledger.1 index 8076c7c4..63017452 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -1,4 +1,4 @@ -.Dd March 10, 2012 +.Dd March 13, 2012 .Dt ledger 1 .Sh NAME .Nm ledger @@ -415,6 +415,7 @@ appeared in the original journal file. .It Fl \-strict .It Fl \-subtotal Pq Fl s .It Fl \-tail Ar INT +.It Fl \-time-report .It Fl \-total Ar EXPR .It Fl \-total-data Pq Fl J .It Fl \-total-width Ar INT diff --git a/src/report.cc b/src/report.cc index cf227fe6..e93bd6fd 100644 --- a/src/report.cc +++ b/src/report.cc @@ -1224,6 +1224,7 @@ option_t<report_t> * report_t::lookup_option(const char * p) else OPT(total_data); else OPT(truncate_); else OPT(total_width_); + else OPT(time_report); break; case 'u': OPT(unbudgeted); diff --git a/src/report.h b/src/report.h index 6322aeb8..c0398d4c 100644 --- a/src/report.h +++ b/src/report.h @@ -324,6 +324,7 @@ public: HANDLER(start_of_week_).report(out); HANDLER(subtotal).report(out); HANDLER(tail_).report(out); + HANDLER(time_report).report(out); HANDLER(total_).report(out); HANDLER(total_data).report(out); HANDLER(truncate_).report(out); @@ -947,6 +948,25 @@ public: OPTION(report_t, subtotal); // -s OPTION(report_t, tail_); + OPTION_(report_t, time_report, DO() { + OTHER(balance_format_) + .on(none, + "%(justify(earliest_checkin ? " + " format_datetime(earliest_checkin) : \"\", 19, -1, true)) " + "%(justify(latest_checkout ? " + " format_datetime(latest_checkout) : \"\", 19, -1, true)) " + "%(ansify_if(" + " justify(scrub(display_total), 8," + " 8 + 4 + 19 * 2, true, color), bold if should_bold))" + " %(!options.flat ? depth_spacer : \"\")" + "%-(ansify_if(" + " ansify_if(partial_account(options.flat), blue if color)," + " bold if should_bold))\n%/" + "%$1 %$2 %$3\n%/" + "%(prepend_width ? \" \" * int(prepend_width) : \"\")" + "--------------------------------------------------\n"); + }); + OPTION__ (report_t, total_, // -T DECL1(report_t, total_, merged_expr_t, expr, ("total_expr", "total")) {} diff --git a/test/baseline/opt-time-report.test b/test/baseline/opt-time-report.test new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/baseline/opt-time-report.test |