out-of-cheese-error / the-way

A code snippets manager for your terminal.
MIT License
352 stars 16 forks source link

[suggestion] layered configuration and relative path in configuration #162

Open oliverdding opened 3 months ago

oliverdding commented 3 months ago

Nice work! I was thinking about writing a snippets manager some time before then I saw this project.

But there are something to improve in configuration. People would include their dotfiles in sync, so a absolute path (like db_dir = '/home/username/.local/share/the_way_db') would not be a good idea, since the username would change in different devices.


At first, I think the path should just start from user home, for example: db_dir = '.local/share/the_way_db', but this would break the backforward compatibility. So I suggest accepting relative path (such as ~) or environment variable (such as $HOME, $XDG_DATA_HOME) in the configuration file.

Take another project for example, gopass is a password manager, which also encounter this issue, see also: issue and pull request.


Another advice is layered configuration. I have seen the default configuration implementation in the code, but if you delete some line in ~/.config/the-way/default-config.toml, such as db_dir, the-way would panic with error like can't parse config file.

That is not good behavior. I think the-way should accpect part of the whole configuration and use the default one if it's not provided. See also The Twelve-Factor App.