rust-cli / confy

🛋 Zero-boilerplate configuration management in Rust
Other
896 stars 59 forks source link

Custom Name for Config Files #30

Closed strix closed 3 years ago

strix commented 4 years ago

First of all, I love the convenience that this package provides but I ran into a problem that might have a simple solution. I want to have multiple config files per project. For example, I would like to store/load the following files on Linux:

~/.config/app-name/config1.toml
~/.config/app-name/config2.toml
~/.config/app-name/config3.toml

With confy's current functionality I can only generate a ~/.config/app-name/app-name.toml file but I'd like to have multiple configs per project.

I've got a quick solution working for me on a fork but it would be nice if this kind of functionality could be in the official package.

matthiasbeyer commented 4 years ago

Why can't you use the load() function with load("config1"), load("config2") and so on?

strix commented 4 years ago

Why can't you use the load() function with load("config1"), load("config2") and so on?

Doing that (on Linux) would result in:

~/.config/config1/config1.toml
~/.config/config2/config2.toml

This happens because the name parameter is being used for both retrieving the config path (using ProjectDirs::from) and to set the file name.

matthiasbeyer commented 4 years ago

Ah. Sure. Did not read the code close enough. Well, I'm not sure about the others, but I'd love to see a patch for that usecase.

deg0nz commented 4 years ago

I have the exact same use case. It would be nice to have a comment by the maintainers if this behaviour is wanted or not; since it could/would add more complexity to the usage of the API and the goal of this crate is to make configs as easy as possible.