Skip to content

pager optimization#34

Open
Balaji01-4D wants to merge 5 commits intomainfrom
fix/pager-optimization
Open

pager optimization#34
Balaji01-4D wants to merge 5 commits intomainfrom
fix/pager-optimization

Conversation

@Balaji01-4D
Copy link
Copy Markdown
Owner

fix the pager optimization and add config pager mode.

Copilot AI review requested due to automatic review settings April 19, 2026 02:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes pager behavior/optimization in the CLI output layer and introduces a configurable pager mode (auto|always|never) exposed via the config file.

Changes:

  • Add pager to the main config schema + default config TOML and validate allowed values.
  • Update PgxPrinter to support pager modes and to decide pager usage based on output size/line count.
  • Extend unit tests for config loading/validation and pager-related printer behavior.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/config/config.go Adds Pager field to the config struct.
internal/config/config.toml Introduces default pager = "auto" and documents modes.
internal/config/validate.go Validates pager presence and allowed values.
internal/config/config_test.go Asserts pager config is loaded/merged correctly.
internal/config/validate_test.go Adds coverage for empty/invalid pager mode validation on load.
internal/cliio/printer.go Implements pager mode support and pager-use heuristics; refactors pager resolution.
internal/cliio/printer_test.go Adds tests for pager mode parsing, heuristics, and newline handling.
internal/cli/root.go Applies configured pager mode to the printer during CLI initialization.
internal/cli/flags.go Formatting-only change.
Comments suppressed due to low confidence (1)

internal/cliio/printer.go:197

  • tryPipePager creates a StdinPipe before calling cmd.Start(), but if cmd.Start() fails it returns without closing the pipe. This can leak file descriptors in error scenarios. Close stdin when cmd.Start() returns an error (and consider cleaning up similarly for other early returns).
	stdin, err := cmd.StdinPipe()
	if err != nil {
		return false
	}
	if err := cmd.Start(); err != nil {
		return false

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/config/validate.go Outdated
Comment thread internal/cliio/printer.go Outdated
Signed-off-by: Balaji J <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants