@@ -31,7 +31,7 @@ def run():
31
31
grafana-wtf [options] explore dashboards
32
32
grafana-wtf [options] find [<search-expression>]
33
33
grafana-wtf [options] replace <search-expression> <replacement> [--dry-run]
34
- grafana-wtf [options] log [<dashboard_uid>] [--number=<count>]
34
+ grafana-wtf [options] log [<dashboard_uid>] [--number=<count>] [--head=<count>] [--tail=<count>] [--reverse]
35
35
grafana-wtf --version
36
36
grafana-wtf (-h | --help)
37
37
@@ -221,11 +221,21 @@ def run():
221
221
222
222
if options .log :
223
223
entries = engine .log (dashboard_uid = options .dashboard_uid )
224
- entries = sorted (entries , key = itemgetter ("datetime" ), reverse = True )
224
+ entries = sorted (entries , key = itemgetter ("datetime" ))
225
225
226
226
if options .number is not None :
227
- count = int (options .number )
228
- entries = entries [:count ]
227
+ limit = int (options .number )
228
+ entries = entries [- limit :]
229
+ options .reverse = True
230
+ elif options .tail is not None :
231
+ limit = int (options .tail )
232
+ entries = entries [- limit :]
233
+ elif options .head is not None :
234
+ limit = int (options .head )
235
+ entries = entries [:limit ]
236
+
237
+ if options .reverse :
238
+ entries = list (reversed (entries ))
229
239
230
240
if output_format .startswith ("tabular" ):
231
241
report = TabularEditHistoryReport (data = entries )
0 commit comments