From 63e960f882a991692eb2224382965cea5e64de21 Mon Sep 17 00:00:00 2001 From: Janik von Rotz Date: Thu, 27 Nov 2025 13:50:20 +0100 Subject: [PATCH] feat(task): standardize TASK_CONFIG_DIR variable and update documentation - Introduce consistent `TASK_CONFIG_DIR` default assignment across environment-related functions - Set default value to `"$HOME/.config/taskfile.build"` with flexibility for override - Update `library.md` to document `TASK_CONFIG_DIR` usage and defaults - Improve formatting and structure of configuration examples in documentation - Maintain existing functionality and code style throughout affected scripts --- bin/init-config-dir | 2 ++ bin/load-env | 1 + bin/remove-env | 2 ++ bin/rename-env | 1 + bin/restore-env-files | 2 +- bin/show-env | 3 +-- library.md | 9 ++++++++- 7 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/init-config-dir b/bin/init-config-dir index 725c6e5..94af028 100755 --- a/bin/init-config-dir +++ b/bin/init-config-dir @@ -1,6 +1,8 @@ #!/usr/bin/env bash init-config-dir() { + TASK_CONFIG_DIR=${TASK_CONFIG_DIR:="$HOME/.config/taskfile.build"} + echo "Ensure $TASK_CONFIG_DIR exists" mkdir -p "$TASK_CONFIG_DIR" } diff --git a/bin/load-env b/bin/load-env index ec2dbe9..21af826 100755 --- a/bin/load-env +++ b/bin/load-env @@ -2,6 +2,7 @@ load-env() { TASK_CONFIG_DIR=${TASK_CONFIG_DIR:="$HOME/.config/taskfile.build"} + local env_filepath="$TASK_CONFIG_DIR/.env.$1" echo "Source env file $env_filepath" source "$env_filepath" diff --git a/bin/remove-env b/bin/remove-env index dd5eeba..b2dfa74 100755 --- a/bin/remove-env +++ b/bin/remove-env @@ -2,6 +2,8 @@ remove-env() { if [[ -z "$1" ]]; then echo "\$1 is empty."; exit; fi + TASK_CONFIG_DIR=${TASK_CONFIG_DIR:="$HOME/.config/taskfile.build"} + local env_filepath="$TASK_CONFIG_DIR/.env.$1" rm "$env_filepath" } \ No newline at end of file diff --git a/bin/rename-env b/bin/rename-env index dce097e..6ae3dcd 100755 --- a/bin/rename-env +++ b/bin/rename-env @@ -4,6 +4,7 @@ rename-env() { if [[ -z "$1" ]]; then echo "\$1 is empty."; exit; fi if [[ -z "$2" ]]; then echo "\$2 is empty."; exit; fi TASK_CONFIG_DIR=${TASK_CONFIG_DIR:="$HOME/.config/taskfile.build"} + local source_env="$TASK_CONFIG_DIR/.env.$1" local target_env="$TASK_CONFIG_DIR/.env.$2" echo "Rename $1 to $2." diff --git a/bin/restore-env-files b/bin/restore-env-files index 4b9042a..2bfeb60 100755 --- a/bin/restore-env-files +++ b/bin/restore-env-files @@ -2,8 +2,8 @@ restore-env-files() { if [[ -z "$1" ]]; then echo "\$1 is empty."; exit; fi + TASK_CONFIG_DIR=${TASK_CONFIG_DIR:="$HOME/.config/taskfile.build"} - TASK_CONFIG_DIR=${TASK_CONFIG_DIR:-$HOME/.config/taskfile.build} local backup_filepath="$1" echo "Restore env files from: $backup_filepath" diff --git a/bin/show-env b/bin/show-env index 4f71072..e3b0e9a 100755 --- a/bin/show-env +++ b/bin/show-env @@ -2,10 +2,9 @@ show-env() { if [[ -z "$1" ]]; then echo "\$1 is empty."; exit; fi - TASK_CONFIG_DIR=${TASK_CONFIG_DIR:="$HOME/.config/taskfile.build"} - local env_filepath="$TASK_CONFIG_DIR/.env.$1" + local env_filepath="$TASK_CONFIG_DIR/.env.$1" if [[ ! -f "$env_filepath" ]]; then echo "Environment '$1' not found." return 1 # Exit with non-zero status if file does not exist diff --git a/library.md b/library.md index cae05e2..0578c43 100644 --- a/library.md +++ b/library.md @@ -37,7 +37,8 @@ fi Configure the task commands. ```bash -OPEN_BROWSER=False +OPEN_BROWSER=False # Default: True +TASK_CONFIG_DIR="$HOME/Odoo-Build/config" # Default: "$HOME/.config/taskfile.build" ``` ### init-config-dir @@ -94,6 +95,12 @@ printf "$column" 'activate-venv' '' 'Activate or initialize Python virtual env.' ## Environment +Manage `.env` files in the task config folder. + +```bash +TASK_CONFIG_DIR="$HOME/Odoo-Build/config" # Default: "$HOME/.config/taskfile.build" +``` + ### create-env ```bash