Browse code

boobank-history: add a "count" command-line argument.

Xavier G authored on 08/11/2017 18:40:44
Showing 2 changed files

... ...
@@ -18,5 +18,6 @@ display its contents in your terminal.
18 18
 
19 19
 boobank-history: take a JSON file created by the "boobank history" command and
20 20
 display its contents in your terminal.
21
+Usage: boobank-history <json-file> <count>
21 22
 
22 23
 [1] http://weboob.org/applications/boobank
... ...
@@ -19,11 +19,16 @@ CURRENCIES = {
19 19
 
20 20
 def main():
21 21
     filepath = sys.argv[1]
22
+    max_operations = int(sys.argv[2]) if len(sys.argv) > 2 else None
22 23
     history = get_history(filepath)
23 24
     timestamp = history.get('timestamp', time.time())
24 25
     table = get_table(timestamp)
26
+    i = 0
25 27
     for operation in history.get('data', []):
26 28
         add_operation(table, operation)
29
+        i += 1
30
+        if max_operations and i == max_operations:
31
+            break
27 32
     print(table)
28 33
 
29 34
 def get_history(history_json_path):