summaryrefslogtreecommitdiff
path: root/src/session.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/session.cc')
-rw-r--r--src/session.cc38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/session.cc b/src/session.cc
index bbc196df..f7a8655b 100644
--- a/src/session.cc
+++ b/src/session.cc
@@ -33,6 +33,7 @@
#include "session.h"
#include "commodity.h"
+#include "pool.h"
#include "xact.h"
#include "account.h"
#include "journal.h"
@@ -71,9 +72,9 @@ session_t::session_t()
TRACE_CTOR(session_t, "");
if (const char * home_var = std::getenv("HOME"))
- HANDLER(price_db_).on((path(home_var) / ".pricedb").string());
+ HANDLER(price_db_).on(none, (path(home_var) / ".pricedb").string());
else
- HANDLER(price_db_).on(path("./.pricedb").string());
+ HANDLER(price_db_).on(none, path("./.pricedb").string());
// Add time commodity conversions, so that timelog's may be parsed
// in terms of seconds, but reported as minutes or hours.
@@ -81,6 +82,12 @@ session_t::session_t()
commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET);
else
assert(false);
+
+ // Add a "percentile" commodity
+ if (commodity_t * commodity = commodity_pool->create("%"))
+ commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET);
+ else
+ assert(false);
}
std::size_t session_t::read_journal(std::istream& in,
@@ -213,6 +220,12 @@ void session_t::clean_accounts()
option_t<session_t> * session_t::lookup_option(const char * p)
{
switch (*p) {
+ case 'Q':
+ OPT_CH(download); // -Q
+ break;
+ case 'Z':
+ OPT_CH(price_exp_);
+ break;
case 'a':
OPT_(account_); // -a
break;
@@ -226,17 +239,15 @@ option_t<session_t> * session_t::lookup_option(const char * p)
OPT(input_date_format_);
break;
case 'l':
- OPT(leeway_);
+ OPT_ALT(price_exp_, leeway_);
break;
case 'p':
OPT(price_db_);
+ else OPT(price_exp_);
break;
case 's':
OPT(strict);
break;
- case 'Q':
- OPT_CH(download); // -Q
- break;
}
return NULL;
}
@@ -245,27 +256,12 @@ expr_t::ptr_op_t session_t::lookup(const string& name)
{
const char * p = name.c_str();
switch (*p) {
- case 'd':
- if (is_eq(p, "date"))
- return MAKE_FUNCTOR(session_t::fn_today);
- break;
-
- case 'n':
- if (is_eq(p, "now"))
- return MAKE_FUNCTOR(session_t::fn_now);
- break;
-
case 'o':
if (WANT_OPT()) { p += OPT_PREFIX_LEN;
if (option_t<session_t> * handler = lookup_option(p))
return MAKE_OPT_HANDLER(session_t, handler);
}
break;
-
- case 't':
- if (is_eq(p, "today"))
- return MAKE_FUNCTOR(session_t::fn_today);
- break;
}
// Check if they are trying to access an option's setting or value.