-
Notifications
You must be signed in to change notification settings - Fork 4
Vaults Log should output to $PAGER when available #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
After investigating how best to implement PAGER support across platforms, I recommend the following approach: /**
* Gets the appropriate pager based on environment variables
*/
function getPager(): string | null {
// Check for PAGER environment variable (standard across all platforms)
if (process.env.PAGER) {
return process.env.PAGER;
}
// On Windows, 'more' is a built-in command available in both CMD and PowerShell
if (process.platform === 'win32') {
return 'more';
}
// For Unix-like systems (Linux, macOS), don't assume any default
return null;
} |
This should only be used when the STDOUT is a real terminal. Don't use when the STDOUT is pointing to a pipe. When
Behavior in Specific Scenarios
Implementation Details in GitGit's pager handling is implemented in its
SummaryGit prioritizes robustness by ensuring |
Sample code summarisation:
Will require synthesis into codebase though and I imagine the output handling would be augmented with PAGER if the output format is like a list of items. It would work more similarly to other systemd commands too. This also means piping to stuff works fine too and does involve the pager. |
TTY detection enables subsequent colourisation and font formatting, which represents CLI UI/UX separately. But must be carefully done to preserve machine interpretation - even when just copy pasting from the terminal output. |
https://dandavison.github.io/delta/environment-variables.html#pager-environment-variables - can also backup to |
Uh oh!
There was an error while loading. Please reload this page.
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 bygit log
, which similarly uses a PAGER for its output.Additional context
git log
command is a well-known example of this behavior, and its implementation can serve as a reference. It defaults toless
as the PAGER on Unix-like systems and uses a pager-like mechanism on Windows.$PAGER
).more
are available, and the behavior should mimic Unix systems as closely as possible.Tasks
$PAGER
. On Windows, check for the availability ofmore
or other pagers.The text was updated successfully, but these errors were encountered: