Skip to content

present.pager

pager(contents, command=None)

Display contents in the user's preferred pager. Essentially equivalent to

$ cli-app | less

Parameters:

Name Type Description Default
contents str

String contents to display in their page

required
command list[str] | None

Override the default pager discovery with a given command to run. Defaults to None.

None

Raises:

Type Description
ArcError

if no pager can be found for the user

Source code in /home/runner/work/arc/arc/arc/present/pager.py
def pager(contents: object, command: list[str] | None = None) -> None:
    """Display `contents` in the user's preferred pager.
    Essentially equivalent to
    ```bash
    $ cli-app | less
    ```

    Args:
        contents (str): String contents to display in their page
        command (list[str] | None, optional): Override the default
            pager discovery with a given command to run. Defaults to None.

    Raises:
        ArcError: if no pager can be found for the user
    """
    command = command or [_get_pager_command()]
    subprocess.run(command, input=str(contents).encode("utf-8"))