diff --git a/README.md b/README.md index 56e955a..1a0aa45 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,16 @@ This command will: More about file templating [on wiki](https://github.com/oskvr37/tiddl/wiki/Template-formatting). +## Custom tiddl home path + +You can set `TIDDL_PATH` environment variable to use custom home path for tiddl. + +Example CLI usage: + +```sh +TIDDL_PATH=~/custom/tiddl tiddl auth login +``` + # Development Clone the repository diff --git a/tiddl/config.py b/tiddl/config.py index c5f7a02..a60a590 100644 --- a/tiddl/config.py +++ b/tiddl/config.py @@ -1,15 +1,20 @@ -# 3.0 TODO: change config path to ~/.config/tiddl.json - +from os import environ, makedirs from pydantic import BaseModel from pathlib import Path from tiddl.models.constants import TrackArg, SinglesFilter -HOME_PATH = Path.home() +TIDDL_ENV_KEY = "TIDDL_PATH" + +# 3.0 TODO: rename HOME_PATH to TIDDL_PATH +# 3.0 TODO: add /tiddl to Path.home() +HOME_PATH = Path(environ[TIDDL_ENV_KEY]) if environ.get(TIDDL_ENV_KEY) else Path.home() + +makedirs(HOME_PATH, exist_ok=True) + CONFIG_PATH = HOME_PATH / "tiddl.json" CONFIG_INDENT = 2 - class TemplateConfig(BaseModel): track: str = "{artist} - {title}" video: str = "{artist} - {title}"