In what way did it blow up? You must have hit a bug, using .pg_service should work. Would you care to open an issue on https://github.com/dbcli/pgcli/issues or just dump the error message here so we can investigate?
mulmen@hostname ~> pgcli service=mulmen@db
Traceback (most recent call last):
File "/usr/local/bin/pgcli", line 33, in <module>
sys.exit(load_entry_point('pgcli==3.1.0', 'console_scripts', 'pgcli')())
File "/usr/local/Cellar/pgcli/3.1.0/libexec/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, \*kwargs)
File "/usr/local/Cellar/pgcli/3.1.0/libexec/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/Cellar/pgcli/3.1.0/libexec/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, \*ctx.params)
File "/usr/local/Cellar/pgcli/3.1.0/libexec/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, \*kwargs)
File "/usr/local/Cellar/pgcli/3.1.0/libexec/lib/python3.9/site-packages/pgcli/main.py", line 1311, in cli
pgcli.connect_service(service, user)
File "/usr/local/Cellar/pgcli/3.1.0/libexec/lib/python3.9/site-packages/pgcli/main.py", line 479, in connect_service
service_config, file = parse_service_info(service)
File "/usr/local/Cellar/pgcli/3.1.0/libexec/lib/python3.9/site-packages/pgcli/main.py", line 1508, in parse_service_info
service_file_config = ConfigObj(service_file)
File "/usr/local/Cellar/pgcli/3.1.0/libexec/lib/python3.9/site-packages/configobj.py", line 1229, in __init__
self._load(infile, configspec)
File "/usr/local/Cellar/pgcli/3.1.0/libexec/lib/python3.9/site-packages/configobj.py", line 1318, in _load
raise error
configobj.ParseError: Invalid line ('PG Service File for saved connection parameters') (matched as neither section nor keyword) at line 1.
Looks like it blew up on a comment line at the top of the file. For some reason the file did not have a # before the comment but psql happily ignores that. I added a # and pgcli loads properly.
Nice to hear that it works! I can reproduce it, psql does seem to handle arbitrary text before the first section of .pg_service.conf. Weird. We'll add a workaround as well.
I'm curious how I ended up with that line there actually. Maybe it was a copy-paste that missed a character? Maybe it was an example I grabbed somewhere? I searched but the only occurrence of that string on the indexed web seems to be my own comment. So maybe I did this to myself.