Skip to content

Add --reverse to fedify lookup to reverse output order in traversal/recurse modes #607

@dahlia

Description

@dahlia

fedify lookup is becoming more capable in two different lookup modes:

In both cases, users often want to see results in the opposite order from the natural fetch order. For example, when inspecting a reply chain, one user may want root-to-leaf order, while another may want leaf-to-root order. Similarly, for traversed collection items, reverse output can be useful for quick chronological inspection depending on server ordering.

This issue proposes a --reverse option for fedify lookup that reverses output order. It should not change how references are resolved semantically; it should only affect presentation order of the final emitted objects/items.

--reverse should be compatible with both --traverse and --recurse.

Expected behavior by mode:

  • With --traverse, output traversed items in reverse order.
  • With --recurse, output the resolved chain in reverse order.
  • Without either mode, if multiple input URLs/handles are given, reverse the output order of successfully fetched objects.

Implementation note: full reversal typically requires buffering the collected results before output. This can increase memory usage, so implementation should be explicit about buffering behavior and maintain predictable error handling.

Example invocations:

  • fedify lookup <collection-url> --traverse --reverse
  • fedify lookup <object-url> --recurse=replyTarget --reverse
  • fedify lookup <url1> <url2> <url3> --reverse

Acceptance criteria

  • --reverse is parsed and documented in lookup help.
  • --reverse works with --traverse and reverses emitted item order.
  • --reverse works with --recurse and reverses emitted chain order.
  • --reverse also affects multi-input default lookup output order.
  • Error behavior remains consistent with existing mode semantics (--suppress-errors, timeouts, fetch failures).
  • Tests cover each mode with and without --reverse.

Metadata

Metadata

Assignees

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions