From 71e8d506573fc61271e10fc3d02eea9a5eb8ba01 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 12 Aug 2004 20:20:30 -0400 Subject: gnuplot is supported again (-j and -J) --- NEWS | 28 ++++++++++++++++++++++++++-- main.cc | 14 +++++++++++++- scripts/report | 10 ++++------ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 3d8e4e45..66baf8e1 100644 --- a/NEWS +++ b/NEWS @@ -3,8 +3,8 @@ * 2.0 -- The code base has been rewritten for clarity and consistency. The - code is now simpler, more robust, and a fair bit faster. +- The code base was rewritten for clarity and consistency. It is now + simpler, more robust, and faster. - The most significant feature addition in this version is the use of "value expressions". These are now used in many places to indicate @@ -22,9 +22,33 @@ "-f" flag was seen (i.e., if the LEDGER environment variable is used). +- New "-o FILE" option will output data to the given FILE. If FILE is + "-", the output is the same as the default (stdout). + +- New -j and -J options replace the old -G (gnuplot) option. -j + reports the values column in a way gnuplot can consume, and -J + reports the totals column. An example can be found in + scripts/report. + - New "-y DATEFMT" options will change the date format used throughout ledger. The default is "%Y/%m/%d". +- New -Y and -W options prints yearly and weekly subtotals, just as + the -M option printed monthly subtotals in the previous version. + +- New "-z INTERVAL" allows for more flexible interval reporting. The + sublanguage used will probably mature over time, but for now it + supports expression like: + + monthly + every week + every 3 quarters + weekly from 12/20 + + Note that when using the "from" date, this does not constrain the + report. It is only used for aligning report dates, for example if + you wish weekly reporting to start on Sundays. + - Regexps specified after the command name now apply to account names only. To search on a payee, use "--" to separate the two kinds of regexps. For example, to find a payee named "John" within all diff --git a/main.cc b/main.cc index a47be892..5b4de2f0 100644 --- a/main.cc +++ b/main.cc @@ -15,6 +15,8 @@ static const std::string bal_fmt = "%20T %2_%-n\n"; static const std::string reg_fmt = "%D %-.20P %-.22N %12.66t %12.80T\n\ %/ %-.22N %12.66t %12.80T\n"; +static const std::string plot_value_fmt = "%D %t\n"; +static const std::string plot_total_fmt = "%D %T\n"; static const std::string print_fmt = "\n%D %X%C%P\n %-34N %12o\n%/ %-34N %12o\n"; static const std::string equity_fmt @@ -219,7 +221,7 @@ int main(int argc, char * argv[]) int c, index; while (-1 != (c = getopt(argc, argv, - "+ABb:Ccd:DEe:F:f:Ghi:L:l:MnOo:P:p:QRrS:sT:t:UVvWXYy:Zz:"))) { + "+ABb:Ccd:DEe:F:f:Ghi:JjL:l:MnOo:P:p:QRrS:sT:t:UVvWXYy:Zz:"))) { switch (char(c)) { // Basic options case 'h': @@ -435,6 +437,16 @@ int main(int argc, char * argv[]) total_expr = "MD(MT/(1+(((t-d)/(30*86400))<0?0:((t-d)/(30*86400)))))"; break; + case 'j': + value_expr = "S" + value_expr; + format_string = plot_value_fmt; + break; + + case 'J': + total_expr = "S" + total_expr; + format_string = plot_total_fmt; + break; + default: assert(0); break; diff --git a/scripts/report b/scripts/report index c548792c..be90f896 100755 --- a/scripts/report +++ b/scripts/report @@ -1,17 +1,15 @@ -#!/bin/sh - -args=("$@") -last=${args[`expr ${#args} - 3`]} +#!/bin/bash cd /tmp -ledger "$@" | stripreg > $last +ledger -j reg "$@" > report gnuplot <