Add CLI enhancements: -c/--command, -f/--file, -y/--yes flags and .pgpass SSH tunnel support #1537
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds four major enhancements to pgcli:
-c/--commandsupport: Execute multiple SQL commands sequentially from command line-f/--fileoption: Execute SQL commands from one or more files-y/--yesflag: Bypass confirmation prompts for destructive operations.pgpasssupport with SSH tunnels: Properly use.pgpassauthentication when connecting through SSH tunnelsMotivation
These features improve pgcli's scriptability and automation capabilities:
-cflags allow complex command sequences without temp files-fflag enables SQL script execution similar to psql-yflag removes interactive prompts for CI/CD pipelines.pgpassSSH tunnel support fixes authentication issues when using tunnelsChanges
1. Multiple
-c/--commandparameters (PR #1530)main.pyto accept multiple-coptions2.
-f/--fileoption (PR #1531)--fileoption to execute SQL from files-foptions-cflag (files execute after commands)3.
-y/--yesflag (PR #1533)--yesflag to force destructive commands4.
.pgpassSSH tunnel support (PR #1534).pgpasslookuphost+hostaddrparameters correctlyhostpreserves original hostname for.pgpasshostaddruses 127.0.0.1 for actual connectionpgexecute.pyto supporthostaddrparameterTest Plan
All features include comprehensive tests:
tests/test_main.pytests/test_ssh_tunnel.pyFiles Modified
pgcli/main.py: CLI argument parsing and execution logicpgcli/pgexecute.py: SSH tunnel connection handlingtests/: Comprehensive test coverage for all featureschangelog.rst: Documented changespyproject.toml: Updated dependenciesVersion
Bumped to 4.3.4
🤖 Generated with Claude Code