chihaya icon indicating copy to clipboard operation
chihaya copied to clipboard

Load config from dotfiles & create default config

Open jzelinskie opened this issue 3 years ago • 4 comments

Right now running chihaya requires a config file to execute. This creates an awkward first experience where the user must preemptively write a config file before they can even run the program.

A few suggestions to improve this situation:

  • Switch from default of /etc/chihaya/config.yaml to $XDG_CONFIG_HOME/chihaya/config.yaml. /etc is most commonly used by system packaged software and chihaya is more likely to be go installed than installed from system package management.
  • Create and write the default config if it is not detected.

jzelinskie avatar May 15 '21 22:05 jzelinskie

Hmm yes, I do agree. How does $XDG_CONFIG_HOME behave with docker?

I'm not sure about the default-config writing. I think it's nice, but it also has the potential of confusion, e.g. if a user forgot to set an explicit config path and is changing a config file in a different location. Something like: "I'm setting this up and trying stuff out, so I have a config file here that I'm editing. Why are my edits not doing anything but there's also no warning etc.?". We could add a prompt, but that's probably annoying if people don't run interactively (the first time at least). Or maybe just print a big warning or so...

mrd0ll4r avatar May 16 '21 14:05 mrd0ll4r

How does $XDG_CONFIG_HOME behave with docker?

Depends on the distro inside the container. Rather than being distracted by XDG, consider the actual decision to read configs by default from a dotfile dir like ~/.chihaya/, rather than /etc/. XDG is just nice to support if it's set.

I think it's nice, but it also has the potential of confusion, e.g. if a user forgot to set an explicit config path and is changing a config file in a different location.

As you said, logging where the config is loaded from should fix this. I think creating the config is desirable, because it gives you a starting place to modify that you know is absolutely compatible with the version of the software that you're running. Right now people have to look at an example from git and hope they're on the right branch/commit of their build.

jzelinskie avatar May 17 '21 03:05 jzelinskie

I like the ~/.chihaya/ automatic loading (if present) and the notation at launch of which config was loaded. For config creation I am a huge fan of the error (lack of config passed on CLI, and no config at default locations) to indicate a --genconf sort of thing where it will spit out the config for you (but this is not automatically done).

Aranjedeath avatar Jul 07 '21 23:07 Aranjedeath

Allow passing configuration options via the command line would be great, too. At least, the most important/required ones, which would override config file or make it unnecessary. I would also allow a cleaner Docker deployment, so configuration would live only in deployment manifests (eg. Docker Compose).

pataquets avatar Aug 02 '22 16:08 pataquets