cli: add 'config init' command

This commit is contained in:
Dima Gerasimov 2020-05-25 12:21:31 +01:00
parent 7bd7cc9228
commit e351c8ba49
4 changed files with 51 additions and 31 deletions

13
my/core/preinit.py Normal file
View file

@ -0,0 +1,13 @@
from pathlib import Path
def get_mycfg_dir() -> Path:
import appdirs # type: ignore[import]
import os
# not sure if that's necessary, i.e. could rely on PYTHONPATH instead
# on the other hand, by using MY_CONFIG we are guaranteed to load it from the desired path?
mvar = os.environ.get('MY_CONFIG')
if mvar is not None:
mycfg_dir = Path(mvar)
else:
mycfg_dir = Path(appdirs.user_config_dir('my'))
return mycfg_dir