Open lnussbaum opened 1 year ago
here is a tested patch:
diff --git a/src/renault_api/cli/charge/history.py b/src/renault_api/cli/charge/history.py
index 7cbf988..9311f7c 100644
--- a/src/renault_api/cli/charge/history.py
+++ b/src/renault_api/cli/charge/history.py
@@ -1,4 +1,5 @@
"""CLI function for a vehicle."""
+import json
from typing import Any
from typing import Dict
from typing import List
@@ -33,6 +34,9 @@ async def sessions(
details = await vehicle.get_details()
response = await vehicle.get_charges(start=parsed_start, end=parsed_end)
charges: List[Dict[str, Any]] = response.raw_data["charges"]
+ if ctx_data["json"]:
+ click.echo(json.dumps(charges))
+ return
if not charges: # pragma: no cover
click.echo("No data available.")
return
Why didn't you create a Pull Request?
Note: the json
option was originally intended for the raw http requests, but I'm happy to merge your code if you provide a pull request.
... it outputs a text table.