smithfarm / dochazka-cli

Dochazka CLI client
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Scan system-wide and user configuration directories in order #37

Open smithfarm opened 8 years ago

smithfarm commented 8 years ago

In CLI, each user needs to be able to tweak his or her own configuration, so dochazka-cli needs to not only scan the system-wide configuration directory (/etc/dochazka-cli) but also the user's own local configuration directory ($HOME/.dochazka-cli).

Implementation of this feature should include documentation changes in CLI_Config.pm and ext/CLI_SiteConfig.pm.

smithfarm commented 8 years ago

Ah! It already scans for /etc/dochazka-cli and $HOME/.dochazka-cli but it's "either, or" - not both.

smithfarm commented 8 years ago

App::MREST::CLI/init_cli_client currently takes only a single sitedir parameter. It needs to take a list of sitedirs, and it shouldn't care if they do or don't exist.

Then, modify dochazka-cli script to pass "/etc/dochazka-cli" and "$HOME/.dochazka-cli" without checking if they exist or not.

tampakrap commented 8 years ago

actually I disagree, I prefer the current workflow. If ~/.dochazka-cli exists, load it. If it doesn't, if /etc/dochazka-cli exists load it. Else ERROR: no config found. This is how usually cli tools work

smithfarm commented 8 years ago

The inspiration for this is, e.g., bash. When started, bash first loads the system bashrc, then the user bashrc.

If there is a possibility to have a system-wide configuration directory and a user configuration directory, then they should both be scanned IMO.

Imagine the following scenario: all employees run dochazka-cli from a single machine where they each have an account. The admin of that machine can set certain parameters globally in /etc/dochazka-cli yet users still have the ability to set other parameters individually in ~/.dochazka-cli.

smithfarm commented 8 years ago

In our case, each employee will run dochazka-cli from his own machine, but if both directories are scanned the packager has the option of overriding default config param values in /etc/dochazka-cli.

tampakrap commented 8 years ago

the idea of having a global /etc/dochazka-cli for many users is valid, but the issue can be solved with the environment variables I proposed in https://github.com/smithfarm/dochazka/issues/6

I am not going to hardcode any vars in the config in the package ftr, I am going to use configuration management to handle that file in production