Page MenuHomePhabricator

[logs-cli] Add `--direction` flag to choose the direction of the logs shown
Closed, ResolvedPublic

Description

This is already implemented on the API side (https://api-docs.toolforge.org/docs#/Logs/logs_get_tool_logs), it's just exposing it on the cli with the same values.

Usage:

<logs-cli> --direction oldest_first/newest_first

(default: oldest_first)

Usage in combination with other flags:

{todo}

Event Timeline

aputhin updated the task description. (Show Details)
dcaro raised the priority of this task from Low to High.Sep 14 2026, 4:21 PM
dcaro moved this task from Backlog to Todos on the tools-platform-team board.
dcaro added a project: OKR-Work.
dcaro changed the task status from Open to In Progress.Oct 5 2026, 9:24 AM
dcaro claimed this task.
dcaro moved this task from Todos to In progress on the tools-platform-team board.

I think adding the --direction option is useful, but is not covering a common use case: printing the last X lines in the log, oldest to newest.

Currently --lines 10 will print the oldest 10 lines (starting at --since), oldest to newest. Adding --direction newest_to_oldest would print the last 10 lines, but in the reverse order.

This would also be useful when combined with streaming logs: print the most recent 10 lines oldest_to_newest, then wait for more lines as they arrive.

I think adding the --direction option is useful, but is not covering a common use case: printing the last X lines in the log, oldest to newest.

That's why I was suggesting using --first/--last before, to get the first N lines of the selected lines, or the last N lines of the selected lines, having --direction newest_first --last 10 will give you the oldest 10 lines, newest to oldest, while --direction newest_first --first 10 would give you the newest 10 lines, newest to oldest, and using it in combination with --direction oldest_first would give you the same results, but ordered oldest to newest.

We can discuss again in the refinement if you want, though last time it was decided to wait for the cli guidelines and/or coding guidelines, as this is mostly a UX issue that would fit there.

this is mostly a UX issue that would fit there.

Agreed, this is a UX issue and should not block this task. Maybe we can track this specific feature (--first/last) it in a separate task?

dcaro moved this task from In progress to Done on the tools-platform-team board.