summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commodity.cc17
-rw-r--r--src/commodity.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/src/commodity.cc b/src/commodity.cc
index cfbab246..4b73b41f 100644
--- a/src/commodity.cc
+++ b/src/commodity.cc
@@ -988,4 +988,21 @@ commodity_t * commodity_pool_t::find_or_create(commodity_t& comm,
return create(comm, details, name);
}
+void commodity_pool_t::parse_commodity_price(const char * optarg)
+{
+ char * equals = std::strchr(optarg, '=');
+ if (! equals)
+ return;
+
+ optarg = skip_ws(optarg);
+ while (equals > optarg && std::isspace(*(equals - 1)))
+ equals--;
+
+ std::string symbol(optarg, 0, equals - optarg);
+ amount_t price(equals + 1);
+
+ if (commodity_t * commodity = commodity_t::find_or_create(symbol))
+ commodity->add_price(datetime_t::now, price);
+}
+
} // namespace ledger
diff --git a/src/commodity.h b/src/commodity.h
index bff8c1c4..56d9f5b2 100644
--- a/src/commodity.h
+++ b/src/commodity.h
@@ -598,6 +598,8 @@ public:
commodity_t * find_or_create(commodity_t& comm,
const annotation_t& details);
+
+ void parse_commodity_price(const char * optarg);
};
} // namespace ledger