Don't depend on postgres running to generate config file
Can you generate the default config file as part of the distribution so packagers can place it on the file system when it's installed like it happens for most applications? Or can you make a flag like pgcli --create-config that creates the default config file without needing postgres to be running?
In some cases postgres isn't running like in chroot or the database is down for maintenance but it's still necessary to modify pgcli's config files such as when setting up a new system.
You don't need to have postgres to exist in order to generate the config file. When you first launch pgcli it will create the config file if it doesn't exist. Since you'd like to create the config without connecting to a real database, you can run pgcli -l or pgcli --list which is designed to list all available databases. But if it can't connect to a database this command will print an error but the config file will still get generated.
Will that be sufficient for your use case?
I was doing it that way but because the command fails it breaks the automated setup script and it makes an error in the script logs which can confuse who is running it. I don't want to hide the log or error code in case there's something else going on. Would prefer a flag like --create-config which just does that and no error.
I think it would be better to bundle the file with the distribution since it's a standard for most applications. It could go under /etc/pgcli/config so people doing automated setups can copy it to ~/.config/pgcli/config and modify it from scripts, and others who don't care will have it generated automatically like now. Package managers like dpkg and pacman have commands that let you list the files included with it which is useful for administrators. And it's easy to compare the differences by diffing the files.
I'm ok adding a config option to create config. I should say that we don't create any of the OS packages. We only create a python package. The python package does ship with the config file, it's just in the python package root which is why we copy it over to a more accessible place on the first launch.
The AUR, DEB and RPM packages were created by volunteers from the respective operating systems. So we don't control how the config file is placed.
I'll work on the config flag.