Skip to content

Vaults Log should output to $PAGER when available #379

@CMCDragonkai

Description

@CMCDragonkai

Specification

When executing the polykey vaults log command, the CLI should automatically detect and utilize the system's PAGER (e.g., less, more) if it exists. If no PAGER is available, the command should default to streaming the output directly to the terminal. This behavior should be consistent across different operating systems, including Windows and MacOS. The implementation should be inspired by git log, which similarly uses a PAGER for its output.

Additional context

  • Prior Work: The git log command is a well-known example of this behavior, and its implementation can serve as a reference. It defaults to less as the PAGER on Unix-like systems and uses a pager-like mechanism on Windows.
  • Cross-Platform Considerations:
    • On Unix-like systems (e.g., MacOS, Linux), the PAGER is typically set in the environment variables (e.g., $PAGER).
    • On Windows, common pagers like more are available, and the behavior should mimic Unix systems as closely as possible.
    • If no PAGER is detected, the output should stream directly to the terminal, ensuring the command remains functional even in environments without a PAGER.
  • https://unix.stackexchange.com/a/213369/56970

Tasks

  1. Pager Detection: Implement logic to detect the presence of a PAGER in the system environment variables. On Unix-like systems, check for $PAGER. On Windows, check for the availability of more or other pagers.
  2. Fallback Mechanism: If no PAGER is detected, ensure the command streams the output directly to the terminal.
  3. Cross-Platform Integration: Ensure the implementation works consistently across Unix-like systems and Windows, handling the differences in how pagers are managed on each platform.
  4. Testing: Implement unit tests and integration tests to verify the behavior in different environments (with/without PAGER, on Windows/MacOS/Linux).
  5. Documentation: Update the CLI documentation to reflect this behavior, including examples of how to set a custom PAGER if desired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions