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
This commit is contained in:
Janik von Rotz committed 2025-11-27 13:50:20 +01:00
1 parent 2490a7329a
commit 63e960f882
7 files changed
+16 -4

No files matched your search

+2
View File
@@ -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"
}
+1
View File
@@ -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"
+2
View File
@@ -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"
}
+1
View File
@@ -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."
+1 -1
View File
@@ -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"
+1 -2
View File
@@ -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
+8 -1
View File
@@ -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