Skip to content

Output destination routing (--output file/clip/stdout/all) and pager research #59

Description

@djdarcy

Output destination routing and optional paging

Problem

When running unbounded or large enumerations like --expr "tri(n)" --max-n 100000, the output floods the terminal and the user loses shell history. Users can pipe to less or redirect to a file, but:

  1. They have to know to do that before running the command
  2. There's no built-in way to write to both stdout and file simultaneously (tee)
  3. Clipboard output is useful for quick results but requires external tools
  4. A built-in pager or buffer would let users maintain control of their terminal without pre-planning

Proposal

Add --output / -o flag supporting multiple destinations, modeled on the listall.py pattern from Z:\OmniTools\listall:

--output stdout       (default, current behavior)
--output file         (write to auto-timestamped file)
--output clip         (copy to clipboard)
--output all          (all three)
--output file,stdout  (comma-separated for specific combos)

Optional: --filename / -F for custom output filename when using --output file.

Buffer / Pager Concept (research)

The more speculative part: should we buffer large enumerations and present them through a pager (like less) by default when output exceeds a threshold? Arguments:

For built-in paging:

  • Protects users from runaway stdout filling their terminal
  • No pre-planning needed ("I forgot to pipe to less")
  • Could integrate with --limit as a soft vs. hard cap

Against built-in paging:

  • Users can already | less or | head
  • Pager behavior varies across platforms (Windows vs. Unix)
  • Adding pager logic to a math tool is scope creep
  • --limit N already provides a hard cap

This may be best left as a "document the pattern" rather than implement — show users in help/docs that | less and > file.txt are the recommended approaches for large output, and keep --output file as the built-in alternative.

Reference

The Z:\OmniTools\listall\listall.py output routing:

  • output_results() function (lines 572-592): multi-destination router
  • --output uses action="append" with set-based expansion ("all"{clip, stdout, file})
  • Auto-timestamped filenames: listall_25.01.13_14-30_EST.txt
  • Content fully assembled in memory, then routed — no streaming/paging

Placement

v1.0 milestone — fits under "Stable CLI interface" alongside output formatting (#55) and enhanced JSON (#35). The output routing is a CLI maturity feature, not a math/enumeration feature.

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions