insanum / sncli

Simplenote CLI
MIT License
396 stars 34 forks source link

Allow specifying config via SNCLIRC environment variable #83

Closed vrillusions closed 5 years ago

vrillusions commented 5 years ago

Will now check the following places for a config file and will try the first one in list:


I try to make use of the ~/.config directory for storing config files. This was the smallest change I could figure out to achieve this. This lets me set export SNCLI="${HOME}/.config/sncli/snclirc" where I can then specify directories for any other config item (ex changing the path of the db directory)

Some basic testing to verify logic:

$ pipenv run ./sncli
Config file not found: '/home/vr/.snclirc'.
$ pipenv run ./sncli --config /tmp/nonexistent-file
Config file not found: '/tmp/nonexistent-file'.
$ SNCLIRC=/tmp/nonexistent-file-from-env pipenv run ./sncli --config /tmp/nonexistent-file
Config file not found: '/tmp/nonexistent-file'.
$ SNCLIRC=/tmp/nonexistent-file-from-env pipenv run ./sncli
Config file not found: '/tmp/nonexistent-file-from-env'.
vrillusions commented 5 years ago

Updated the section in README. Couldn't think of a good way to update the usage output to mention the environment variable. In a lot of other projects it seems like environment variables is an advanced option and usually just mentioned in README or other online documentation.

samuelallan72 commented 5 years ago

Thanks!