From 8e93e4ec9a5961950dffde6da066dff2ab2f4c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Dudzi=C5=84ski?= <56404247+oskvr37@users.noreply.github.com> Date: Thu, 20 Mar 2025 14:28:39 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20'TIDDL=5FPATH'=20env=20vari?= =?UTF-8?q?able=20for=20custom=20`HOME=5FPATH`=20(#109)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++++++++ tiddl/config.py | 13 +++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) 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}"