show_log: support names 'last' and 'last-x' in path

Co-authored-by: manor-tile <159947643+manor-tile@users.noreply.github.com>
This commit is contained in:
BELLAHBIB Ayoub 2024-03-17 18:58:22 +01:00 committed by manor-tile
parent df49295836
commit f9d3ae1084
2 changed files with 11 additions and 1 deletions

2
share/actionsmap.yml Normal file → Executable file
View file

@ -1976,7 +1976,7 @@ log:
- display
arguments:
path:
help: Log file which to display the content
help: Log file which to display the content, or 'last' or 'last-X' to get the log in last-X position
-n:
full: --number
help: Number of lines to display

10
src/log.py Normal file → Executable file
View file

@ -173,6 +173,16 @@ def log_show(
share
"""
match_path = re.match(r"last(?:-(?P<position>[0-9]{1,6}))?$", path)
if match_path:
if match_path.group("position") == None:
position = 1
else:
position = int(match_path.group("position")) + 1
logs = log_list()
path = list(logs["operation"])[-position]["path"]
if share:
filter_irrelevant = True