Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-part configurations #4

Open
spacekookie opened this issue May 28, 2018 · 5 comments
Open

Multi-part configurations #4

spacekookie opened this issue May 28, 2018 · 5 comments
Labels
enhancement New feature or request

Comments

@spacekookie
Copy link
Contributor

Should it be possible to have a global config that is overwritten by a local/ user config, etc. And how would be the best way to implement this?

Suggested by #2 (comment)

@gibix
Copy link

gibix commented May 28, 2018

default in: $HOME/.$BINARYNAME.$EXTENSION overrided by an Option<Path>

This sounds good?

struct Confy {
    cfg_in: Option<Path>,
    cfg_out: Option<Path>,
}

impl Confy {
    new(cfg_in, cfg_out) -> Confy... // if cfg_in.is_none() check for default
    load...
    write...
}

@Dylan-DPC-zz
Copy link

@gibix looks good but do we need to make the inputs optional?

@gibix
Copy link

gibix commented May 28, 2018

Confy { None, None } maps to default values

@kamalmarhubi
Copy link

kamalmarhubi commented May 28, 2018

Please use app_dirs or one of the replacements for the default config path. (I forget which is the "most bestest" at the moment.)

I think it's well worth surveying how different systems handle this. If this is going to be a default suggestion for how to handle config, it should not do anything "objectionable". In this case, I would call using $HOME/.something objectionable: many people will object and say it should put stuff in $HOME/.config/something ($XDG_CONFIG_HOME) or $HOME/Library/...` on Mac.

For example, a typical binary on my (Debian) system will look for files under these directories:

  • vendor provided defaults (ie from author or packager) in /usr/share/something
  • system defaults (for sysadmin to use) /etc/something
  • somewhere in home (for each user)—either $HOME/.something or $XDG_CONFIG_HOME/something depending on how well behaved

Individual settings in each location override the previous locations, so that all files are read in order, and configurations are updated.

@kamalmarhubi
Copy link

kamalmarhubi commented May 28, 2018

Also in #3 (comment), the subject of this issue was pointed out as a non-goal:

Absolute non-goals would for example be: [...] a comprehensive feature list like having multiple config files where fields from one overwrite fields in another.

I don't have strong feelings on whether it's in scope or not for a crate like confy, but I do have strong feelings on doing it right if it ends up being included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants