diff --git a/fioul.py b/fioul.py old mode 100644 new mode 100755 index bbdc0e4..ff2e26d --- a/fioul.py +++ b/fioul.py @@ -32,6 +32,11 @@ def get_price(): return product["default_price_tax"] +def get_prices(n=10): + query = Price.select().order_by(Price.date.desc()).limit(n) + return query + + def store_current_price(): today = date.today() # Get price returns a float (price per L) @@ -63,14 +68,19 @@ def subcommand(args=[], parent=subparsers): return decorator +def argument(*name_or_flags, **kwargs): + return ([*name_or_flags], kwargs) + + @subcommand() def update(args): store_current_price() -@subcommand() +@subcommand([argument("n", default=42, nargs="?", type=int)]) def show(args): - print(get_price()) + for x in get_prices(args.n): + print(x.date, x.price) @subcommand()