Skip to content

refactor(app): isolate local command dispatch - #111

Merged
balajz merged 1 commit into
balajz:mainfrom
dcavalcante:refactor/local-command-dispatch
Aug 15, 2026
Merged

refactor(app): isolate local command dispatch#111
balajz merged 1 commit into
balajz:mainfrom
dcavalcante:refactor/local-command-dispatch

Conversation

@dcavalcante

Copy link
Copy Markdown
Contributor

Summary

This separates client-side command dispatch from the main execution path.

Previously, app.go contained both the local command registry and its lookup logic. This change moves those responsibilities into local_commands.go, leaving execute focused on deciding whether an input should be handled locally or passed to the existing meta-command and SQL execution paths.

The existing \clear command is used to establish this boundary. Its handler, logging, prompt handling, and exact-match behavior remain unchanged.

Changes

  • move the local command registry out of app.go
  • introduce runLocal as the local command lookup and dispatch entry point
  • keep prompt wrapping and logging in the existing execution flow
  • add regression tests for \clear dispatch and exact command matching

Behavior

This is a structural refactor with no intended user-facing changes.

Testing

  • go test ./...
  • go vet ./...
  • golangci-lint run

@dcavalcante
dcavalcante force-pushed the refactor/local-command-dispatch branch from 9ebba94 to 896bf87 Compare August 13, 2026 22:44
@balajz
balajz requested a lite review from Copilot August 15, 2026 01:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refactors the internal/app execution path by extracting local (client-side) command lookup/dispatch out of app.go into a dedicated local_commands.go, keeping execute focused on routing input to local commands vs meta-commands vs SQL execution.

Changes:

  • Moved the local command registry (currently \clear) into internal/app/local_commands.go.
  • Added (*pgxCLI).runLocal(query) as the single entry point for exact-match local command dispatch.
  • Added regression tests to confirm exact-match behavior for \clear and non-matching variants.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/app/local_commands.go Introduces the local command registry and runLocal dispatch method.
internal/app/local_commands_test.go Adds tests to ensure runLocal matches \clear exactly and rejects similar inputs.
internal/app/app.go Switches local command execution to use p.runLocal(query) and preserves prompt-wrapping behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@balajz balajz added this to the v0.3.2 milestone Aug 15, 2026
@balajz

balajz commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Looks great, thanks for working on this!

@balajz
balajz merged commit c390d3f into balajz:main Aug 15, 2026
8 checks passed
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.

3 participants