Added --auto-match option, for use with 'convert'

This commit is contained in:
John Wiegley 2012-02-26 02:16:09 -06:00
parent 5a201971a9
commit 4a18317e7c
5 changed files with 9 additions and 3 deletions

View file

@ -1,4 +1,4 @@
.Dd June 22, 2010
.Dd February 26, 2012
.Dt ledger 1
.Sh NAME
.Nm ledger
@ -270,6 +270,7 @@ transactions they are contained in. See the manual for more information.
.It Fl \-amount-width Ar INT
.It Fl \-anon
.It Fl \-args-only
.It Fl \-auto-match
.It Fl \-average Pq Fl A
.It Fl \-balance-format Ar FMT
.It Fl \-base

View file

@ -123,8 +123,10 @@ value_t convert_command(call_scope_t& args)
if (xact->posts.front()->account == NULL) {
// jww (2010-03-07): Bind this logic to an option: --auto-match
if (account_t * acct =
(report.HANDLED(auto_match) ?
lookup_probable_account(xact->payee, current_xacts.rbegin(),
current_xacts.rend(), bucket).second)
current_xacts.rend(), bucket).second :
NULL))
xact->posts.front()->account = acct;
else
xact->posts.front()->account = unknown;

View file

@ -966,6 +966,7 @@ option_t<report_t> * report_t::lookup_option(const char * p)
else OPT(amount_data);
else OPT(anon);
else OPT_ALT(color, ansi);
else OPT(auto_match);
else OPT(average);
else OPT(account_width_);
else OPT(amount_width_);

View file

@ -229,6 +229,7 @@ public:
HANDLER(amount_).report(out);
HANDLER(amount_data).report(out);
HANDLER(anon).report(out);
HANDLER(auto_match).report(out);
HANDLER(average).report(out);
HANDLER(balance_format_).report(out);
HANDLER(base).report(out);
@ -381,6 +382,7 @@ public:
OPTION(report_t, amount_data); // -j
OPTION(report_t, anon);
OPTION(report_t, auto_match);
OPTION_(report_t, average, DO() { // -A
parent->HANDLER(display_total_)

View file