-
Notifications
You must be signed in to change notification settings - Fork 74
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
tern psql #78
tern psql #78
Conversation
I'm not sure if this feature is the best approach to sharing configuration between tern and other programs (personally, I use PGSERVICE). But would it make sense to generalize this to something like Then it could be used with psql like this:
This would allow passing other arguments to psql as well and using it with other programs that need a connstring. Also, I'm not sure that the conn string generation is correct. Unless I missed something, it will miss any other arguments like |
Yeah I totally overlooked arguments. This should account for the values you can provide via config/cli (ssl mode and cert) and it will just use the connstring if its available from the config file or passed via cli so you can pass anything. As for restructuring to just print out the connstring, I personaly think being able to just use tern to connect is more usable than piping the output of a command to another program but its up to you, I can restructure. |
I realize that
is not as convenient to type as
but I think it is worth it because of the additional flexibility to work with any program and even for But one caveat with this whole feature is it is impossible to create a connstring for all connection configurations tern supports. At the very least SSH tunneling will never work, and I suspect there may be other settings as well. The only way to definitely work with every connection config would be to act as a proxy like I considered in #47. |
I changed it to print-connstring instead. I see your points about flexability and the ability to pass additional arguments. Let me know if I can do anything else |
main.go
Outdated
@@ -958,6 +994,8 @@ func appendConfigFromFile(config *Config, path string) error { | |||
} | |||
|
|||
if connString, ok := file.Get("database", "conn_string"); ok { | |||
config.ConnString = connString | |||
fmt.Println(config.ConnString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this fmt.Println
intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No thanks for catching that. It was just a test print I forgot to delete. Removed in the newest push.
This PR adds a new command
tern psql
. the command launches psql with a connstring derived from the config files/arguments passed to the command. It will look for PSQL_BIN_PATH for an alternative binary, such as pgcli, to use otherwise it will just usepsql connstring
.