Rearranged some of the options code, enabled -t and -T.
This commit is contained in:
parent
7455495d14
commit
6d4bbe97db
2 changed files with 75 additions and 117 deletions
35
report.cc
35
report.cc
|
|
@ -384,16 +384,9 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
|
||||||
if (std::strncmp(p, "opt_", 4) == 0) {
|
if (std::strncmp(p, "opt_", 4) == 0) {
|
||||||
p = p + 4;
|
p = p + 4;
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
#if 0
|
|
||||||
case 'a':
|
case 'a':
|
||||||
if (std::strcmp(p, "amount") == 0)
|
if (std::strcmp(p, "amount_") == 0)
|
||||||
return MAKE_FUNCTOR(report_t::option_amount);
|
return MAKE_FUNCTOR(report_t::option_amount_);
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case 'b':
|
|
||||||
if (std::strcmp(p, "bar_") == 0)
|
|
||||||
return MAKE_FUNCTOR(report_t::option_bar_);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
|
|
@ -402,24 +395,32 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
|
||||||
return MAKE_FUNCTOR(report_t::option_format_);
|
return MAKE_FUNCTOR(report_t::option_format_);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'j':
|
||||||
|
if (! (*p + 1))
|
||||||
|
return MAKE_FUNCTOR(report_t::option_amount_data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'J':
|
||||||
|
if (! (*p + 1))
|
||||||
|
return MAKE_FUNCTOR(report_t::option_total_data);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
if (std::strcmp(p, "l_") || std::strcmp(p, "limit_"))
|
if (std::strcmp(p, "l_") || std::strcmp(p, "limit_"))
|
||||||
return MAKE_FUNCTOR(report_t::option_limit_);
|
return MAKE_FUNCTOR(report_t::option_limit_);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if 0
|
|
||||||
case 't':
|
case 't':
|
||||||
if (! *(p + 1))
|
if (std::strcmp(p, "t_"))
|
||||||
return MAKE_FUNCTOR(report_t::option_amount);
|
return MAKE_FUNCTOR(report_t::option_amount_);
|
||||||
else if (std::strcmp(p, "total") == 0)
|
else if (std::strcmp(p, "total_") == 0)
|
||||||
return MAKE_FUNCTOR(report_t::option_total);
|
return MAKE_FUNCTOR(report_t::option_total_);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'T':
|
case 'T':
|
||||||
if (! *(p + 1))
|
if (std::strcmp(p, "T_"))
|
||||||
return MAKE_FUNCTOR(report_t::option_total);
|
return MAKE_FUNCTOR(report_t::option_total_);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
157
report.h
157
report.h
|
|
@ -187,55 +187,6 @@ public:
|
||||||
chain_xact_handlers(xact_handler_ptr handler,
|
chain_xact_handlers(xact_handler_ptr handler,
|
||||||
const bool handle_individual_transactions = true);
|
const bool handle_individual_transactions = true);
|
||||||
|
|
||||||
//
|
|
||||||
// Config options
|
|
||||||
//
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
void eval(const string& expr) {
|
|
||||||
expr_t(expr).calc(*this);
|
|
||||||
}
|
|
||||||
value_t option_eval(call_scope_t& args) {
|
|
||||||
eval(args[0].as_string());
|
|
||||||
return NULL_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
value_t option_amount_(call_scope_t& args) {
|
|
||||||
eval(string("t=") + args[0].as_string());
|
|
||||||
return NULL_VALUE;
|
|
||||||
}
|
|
||||||
value_t option_total_(call_scope_t& args) {
|
|
||||||
eval(string("T()=") + args[0].as_string());
|
|
||||||
return NULL_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
value_t option_raw(call_scope_t&) {
|
|
||||||
raw_mode = true;
|
|
||||||
return NULL_VALUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
value_t option_format_(call_scope_t& args) {
|
|
||||||
format_string = args[0].as_string();
|
|
||||||
return NULL_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
value_t option_foo(call_scope_t&) {
|
|
||||||
std::cout << "This is foo" << std::endl;
|
|
||||||
return NULL_VALUE;
|
|
||||||
}
|
|
||||||
value_t option_bar_(call_scope_t& args) {
|
|
||||||
std::cout << "This is bar: " << args[0] << std::endl;
|
|
||||||
return args[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
value_t option_limit_(call_scope_t& args) {
|
|
||||||
if (! predicate.empty())
|
|
||||||
predicate += "&";
|
|
||||||
predicate += args[0].as_string();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
|
@ -251,17 +202,17 @@ public:
|
||||||
throw 0;
|
throw 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_help_calc(call_scope_t& args) { //
|
value_t option_help_calc(call_scope_t& args) {
|
||||||
option_calc_help(std::cout);
|
option_calc_help(std::cout);
|
||||||
throw 0;
|
throw 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_help_disp(call_scope_t& args) { //
|
value_t option_help_disp(call_scope_t& args) {
|
||||||
option_disp_help(std::cout);
|
option_disp_help(std::cout);
|
||||||
throw 0;
|
throw 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_help_comm(call_scope_t& args) { //
|
value_t option_help_comm(call_scope_t& args) {
|
||||||
option_comm_help(std::cout);
|
option_comm_help(std::cout);
|
||||||
throw 0;
|
throw 0;
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +248,7 @@ public:
|
||||||
config->cache_file = resolve_path(optarg);
|
config->cache_file = resolve_path(optarg);
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_no_cache(call_scope_t& args) { //
|
value_t option_no_cache(call_scope_t& args) {
|
||||||
config->cache_file = "<none>";
|
config->cache_file = "<none>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -317,11 +268,11 @@ public:
|
||||||
::setenv("DEBUG_CLASS", optarg, 1);
|
::setenv("DEBUG_CLASS", optarg, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_verbose(call_scope_t& args) { //
|
value_t option_verbose(call_scope_t& args) {
|
||||||
config->verbose_mode = true;
|
config->verbose_mode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_trace(call_scope_t& args) { //
|
value_t option_trace(call_scope_t& args) {
|
||||||
config->trace_mode = true;
|
config->trace_mode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -329,7 +280,7 @@ public:
|
||||||
//
|
//
|
||||||
// Report filtering
|
// Report filtering
|
||||||
|
|
||||||
value_t option_effective(call_scope_t& args) { //
|
value_t option_effective(call_scope_t& args) {
|
||||||
xact_t::use_effective_date = true;
|
xact_t::use_effective_date = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -393,32 +344,35 @@ public:
|
||||||
report->predicate += "L";
|
report->predicate += "L";
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_lots(call_scope_t& args) { //
|
value_t option_lots(call_scope_t& args) {
|
||||||
report->keep_price =
|
report->keep_price =
|
||||||
report->keep_date =
|
report->keep_date =
|
||||||
report->keep_tag = true;
|
report->keep_tag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_lot_prices(call_scope_t& args) { //
|
value_t option_lot_prices(call_scope_t& args) {
|
||||||
report->keep_price = true;
|
report->keep_price = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_lot_dates(call_scope_t& args) { //
|
value_t option_lot_dates(call_scope_t& args) {
|
||||||
report->keep_date = true;
|
report->keep_date = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_lot_tags(call_scope_t& args) { //
|
value_t option_lot_tags(call_scope_t& args) {
|
||||||
report->keep_tag = true;
|
report->keep_tag = true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Output customization
|
// Output customization
|
||||||
|
|
||||||
value_t option_format(call_scope_t& args) { // F:
|
value_t option_format_(call_scope_t& args) { // F:
|
||||||
report->format_string = optarg;
|
format_string = args[0].as_string();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
value_t option_date_format(call_scope_t& args) { // y:
|
value_t option_date_format(call_scope_t& args) { // y:
|
||||||
report->date_output_format = optarg;
|
report->date_output_format = optarg;
|
||||||
}
|
}
|
||||||
|
|
@ -511,7 +465,7 @@ public:
|
||||||
report->show_subtotal = true;
|
report->show_subtotal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_totals(call_scope_t& args) { //
|
value_t option_totals(call_scope_t& args) {
|
||||||
report->show_totals = true;
|
report->show_totals = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -519,12 +473,12 @@ public:
|
||||||
report->sort_string = optarg;
|
report->sort_string = optarg;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_sort_entries(call_scope_t& args) { //
|
value_t option_sort_entries(call_scope_t& args) {
|
||||||
report->sort_string = optarg;
|
report->sort_string = optarg;
|
||||||
report->entry_sort = true;
|
report->entry_sort = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_sort_all(call_scope_t& args) { //
|
value_t option_sort_all(call_scope_t& args) {
|
||||||
report->sort_string = optarg;
|
report->sort_string = optarg;
|
||||||
report->entry_sort = false;
|
report->entry_sort = false;
|
||||||
report->sort_all = true;
|
report->sort_all = true;
|
||||||
|
|
@ -539,7 +493,7 @@ public:
|
||||||
report->show_related = true;
|
report->show_related = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_descend(call_scope_t& args) { //
|
value_t option_descend(call_scope_t& args) {
|
||||||
std::string arg(optarg);
|
std::string arg(optarg);
|
||||||
std::string::size_type beg = 0;
|
std::string::size_type beg = 0;
|
||||||
report->descend_expr = "";
|
report->descend_expr = "";
|
||||||
|
|
@ -552,7 +506,7 @@ public:
|
||||||
std::string(arg, beg) + "}");
|
std::string(arg, beg) + "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_descend_if(call_scope_t& args) { //
|
value_t option_descend_if(call_scope_t& args) {
|
||||||
report->descend_expr = optarg;
|
report->descend_expr = optarg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -589,7 +543,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_daily(call_scope_t& args) { //
|
value_t option_daily(call_scope_t& args) {
|
||||||
if (report->report_period.empty())
|
if (report->report_period.empty())
|
||||||
report->report_period = "daily";
|
report->report_period = "daily";
|
||||||
else
|
else
|
||||||
|
|
@ -610,7 +564,7 @@ public:
|
||||||
report->report_period = std::string("monthly ") + report->report_period;
|
report->report_period = std::string("monthly ") + report->report_period;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_quarterly(call_scope_t& args) { //
|
value_t option_quarterly(call_scope_t& args) {
|
||||||
if (report->report_period.empty())
|
if (report->report_period.empty())
|
||||||
report->report_period = "quarterly";
|
report->report_period = "quarterly";
|
||||||
else
|
else
|
||||||
|
|
@ -624,7 +578,7 @@ public:
|
||||||
report->report_period = std::string("yearly ") + report->report_period;
|
report->report_period = std::string("yearly ") + report->report_period;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_dow(call_scope_t& args) { //
|
value_t option_dow(call_scope_t& args) {
|
||||||
report->days_of_the_week = true;
|
report->days_of_the_week = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -636,19 +590,19 @@ public:
|
||||||
report->comm_as_payee = true;
|
report->comm_as_payee = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_code_as_payee(call_scope_t& args) { //
|
value_t option_code_as_payee(call_scope_t& args) {
|
||||||
report->code_as_payee = true;
|
report->code_as_payee = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_budget(call_scope_t& args) { //
|
value_t option_budget(call_scope_t& args) {
|
||||||
report->budget_flags = BUDGET_BUDGETED;
|
report->budget_flags = BUDGET_BUDGETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_add_budget(call_scope_t& args) { //
|
value_t option_add_budget(call_scope_t& args) {
|
||||||
report->budget_flags = BUDGET_BUDGETED | BUDGET_UNBUDGETED;
|
report->budget_flags = BUDGET_BUDGETED | BUDGET_UNBUDGETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_unbudgeted(call_scope_t& args) { //
|
value_t option_unbudgeted(call_scope_t& args) {
|
||||||
report->budget_flags = BUDGET_UNBUDGETED;
|
report->budget_flags = BUDGET_UNBUDGETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -663,15 +617,16 @@ public:
|
||||||
value_t option_reconcile_date(call_scope_t& args) { // :
|
value_t option_reconcile_date(call_scope_t& args) { // :
|
||||||
report->reconcile_date = optarg;
|
report->reconcile_date = optarg;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
value_t option_limit(call_scope_t& args) { // l:
|
value_t option_limit_(call_scope_t& args) { // l:
|
||||||
if (! report->predicate.empty())
|
if (! predicate.empty())
|
||||||
report->predicate += "&";
|
predicate += "&";
|
||||||
report->predicate += "(";
|
predicate += args[0].as_string();
|
||||||
report->predicate += optarg;
|
return true;
|
||||||
report->predicate += ")";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
value_t option_only(call_scope_t& args) { // :
|
value_t option_only(call_scope_t& args) { // :
|
||||||
if (! report->secondary_predicate.empty())
|
if (! report->secondary_predicate.empty())
|
||||||
report->secondary_predicate += "&";
|
report->secondary_predicate += "&";
|
||||||
|
|
@ -687,31 +642,40 @@ public:
|
||||||
report->display_predicate += optarg;
|
report->display_predicate += optarg;
|
||||||
report->display_predicate += ")";
|
report->display_predicate += ")";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
value_t option_amount(call_scope_t& args) { // t:
|
value_t option_amount_(call_scope_t& args) { // t:
|
||||||
ledger::amount_expr = optarg;
|
amount_expr = args[0].as_string();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_total(call_scope_t& args) { // T:
|
value_t option_total_(call_scope_t& args) { // T:
|
||||||
ledger::total_expr = optarg;
|
total_expr = args[0].as_string();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_amount_data(call_scope_t& args) { // j
|
value_t get_amount_expr(call_scope_t& scope);
|
||||||
report->format_string = config->plot_amount_format;
|
value_t get_total_expr(call_scope_t& scope);
|
||||||
|
|
||||||
|
value_t option_amount_data(call_scope_t&) { // j
|
||||||
|
format_string = session.plot_amount_format;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_total_data(call_scope_t& args) { // J
|
value_t option_total_data(call_scope_t&) { // J
|
||||||
report->format_string = config->plot_total_format;
|
format_string = session.plot_total_format;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_ansi(call_scope_t& args) { //
|
#if 0
|
||||||
|
value_t option_ansi(call_scope_t& args) {
|
||||||
format_t::ansi_codes = true;
|
format_t::ansi_codes = true;
|
||||||
format_t::ansi_invert = false;
|
format_t::ansi_invert = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_ansi_invert(call_scope_t& args) { //
|
value_t option_ansi_invert(call_scope_t& args) {
|
||||||
format_t::ansi_codes =
|
format_t::ansi_codes =
|
||||||
format_t::ansi_invert = true;
|
format_t::ansi_invert = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -735,8 +699,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_quantity(call_scope_t& args) { // O
|
value_t option_quantity(call_scope_t& args) { // O
|
||||||
ledger::amount_expr = "a";
|
ledger::amount_expr = "amount";
|
||||||
ledger::total_expr = "O";
|
ledger::total_expr = "total";
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_basis(call_scope_t& args) { // B
|
value_t option_basis(call_scope_t& args) { // B
|
||||||
|
|
@ -781,13 +745,6 @@ public:
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
|
||||||
// Formatting functions
|
|
||||||
//
|
|
||||||
|
|
||||||
value_t get_amount_expr(call_scope_t& scope);
|
|
||||||
value_t get_total_expr(call_scope_t& scope);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Scope members
|
// Scope members
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue