374 lines
7.2 KiB
Markdown
374 lines
7.2 KiB
Markdown
---
|
|
layout: layouts/base.njk
|
|
---
|
|
|
|
# Library
|
|
|
|
The repository of this website provides a library of reusable functions.
|
|
|
|
Clone the repository into your home folder and ensure it is updated regularly.
|
|
|
|
```bash
|
|
clone-taskfile(){
|
|
if [[ ! -d "$HOME/taskfile.build" ]]; then
|
|
echo -e '\033[38;5;214mGit\033[0m: Clone taskfile repo'
|
|
git clone https://git.taskfile.build "$HOME/taskfile.build"
|
|
else
|
|
echo -e '\033[38;5;214mGit\033[0m: Pull taskfile repo'
|
|
git -C "$HOME/taskfile.build" pull
|
|
fi
|
|
}
|
|
```
|
|
|
|
In your task file import all commands from the taskfile library.
|
|
|
|
```bash
|
|
if [[ -d "$HOME/taskfile.build/bin" ]]; then
|
|
for file in "$HOME/taskfile.build/bin/"*; do
|
|
if [[ -f "$file" ]]; then
|
|
source "$file"
|
|
fi
|
|
done
|
|
fi
|
|
```
|
|
|
|
These commands create folder in the directory of the task file and the home directory. Here is an overview of these folders:
|
|
|
|
* `$PWD/tmp`: Temporary directory for the task commands.
|
|
* `$PWD/.prompt`: LLM prompts stored as markdown files.
|
|
* `$HOME/.config/taskfile.build`: Default path for storing dotenv files.
|
|
* `$HOME/.docker/$CONTAINER_REGISTRY`: Default path for storing container registry credentials.
|
|
|
|
## Task
|
|
|
|
Configure the task enviroment.
|
|
|
|
```bash
|
|
OPEN_BROWSER=False # Default: True
|
|
TASK_DOTENV_DIR="$HOME/Odoo-Build/config" # Default: "$HOME/.config/taskfile.build"
|
|
```
|
|
|
|
### clone-taskfile
|
|
|
|
```bash
|
|
printf "$column" 'clone-taskfile' '' 'Clone the taskfile.build repo.'
|
|
```
|
|
|
|
|
|
### init-config-dir
|
|
|
|
```bash
|
|
printf "$column" 'init-dotenv-dir' '' 'Setup task dotenv dir.'
|
|
```
|
|
|
|
### template-dotenv
|
|
|
|
```bash
|
|
printf "$column" 'template-dotenv' '' 'Generate .env from .env.template.'
|
|
```
|
|
|
|
### open-with-os
|
|
|
|
```bash
|
|
printf "$column" 'open-with-os' '' 'Open file or url with default application.'
|
|
```
|
|
|
|
### open-url-with-delay
|
|
|
|
```bash
|
|
printf "$column" 'open-url-with-delay' '[url][delay]' 'Open url after n seconds.'
|
|
```
|
|
|
|
## Files
|
|
|
|
Managing files and directories.
|
|
|
|
### ensure-directory
|
|
|
|
```bash
|
|
printf "$column" 'ensure-directory' '[path]' 'Ensure directory path exists.'
|
|
```
|
|
|
|
### create-symlink
|
|
|
|
```bash
|
|
printf "$column" 'create-symlink' '[target][source]' 'Remove existing file/directory and create symlink.'
|
|
```
|
|
|
|
### create-symlink-files
|
|
|
|
```bash
|
|
printf "$column" 'create-symlink-files' '[target][source]' 'Create symlink for files in source pattern.'
|
|
```
|
|
|
|
## Python
|
|
|
|
Setup Python virtual enviroment.
|
|
|
|
### activate-venv
|
|
|
|
```bash
|
|
printf "$column" 'activate-venv' '' 'Activate or initialize Python virtual env.'
|
|
```
|
|
|
|
### remove-venv
|
|
|
|
```bash
|
|
printf "$column" 'remove-venv' '' 'Remove the Python virtual env.'
|
|
```
|
|
|
|
## Environment
|
|
|
|
Manage `.env` files in the task config folder.
|
|
|
|
```bash
|
|
TASK_DOTENV_DIR="$HOME/Odoo-Build/config" # Default: "$HOME/.config/taskfile.build"
|
|
```
|
|
|
|
### create-env
|
|
|
|
```bash
|
|
printf "$column" 'create-env' '[env][type]' 'Create env file of type nextcloud, odoo, upgrade.'
|
|
```
|
|
|
|
### list-env
|
|
|
|
```bash
|
|
printf "$column" 'list-env' '' 'List env files.'
|
|
```
|
|
|
|
### show-env
|
|
|
|
```bash
|
|
printf "$column" 'show-env' '[env]' 'Output content of the env file.'
|
|
```
|
|
|
|
### copy-env
|
|
|
|
```bash
|
|
printf "$column" 'copy-env' '[env][env]' 'Copy env file.'
|
|
```
|
|
|
|
### edit-env
|
|
|
|
```bash
|
|
printf "$column" 'edit-env' '[env]' 'Open env file in default editor.'
|
|
```
|
|
|
|
### load-env
|
|
|
|
```bash
|
|
printf "$column" 'load-env' '[env]' 'Load and export env file.'
|
|
```
|
|
|
|
### rename-env
|
|
|
|
```bash
|
|
printf "$column" 'rename-env' '[env][env]' 'Rename env file.'
|
|
```
|
|
|
|
### remove-env
|
|
|
|
```bash
|
|
printf "$column" 'remove-env' '[env]' 'Remove environment config.'
|
|
```
|
|
|
|
### backup-env-files
|
|
|
|
```bash
|
|
printf "$column" 'backup-env-files' '[path]' 'Archive and copy env files to target location.'
|
|
```
|
|
|
|
### restore-env-files
|
|
|
|
```bash
|
|
printf "$column" 'restore-env-files' '[path]' 'Extract and copy env files from backup file.'
|
|
```
|
|
|
|
## LLM
|
|
|
|
Commands that integrate the `llm` cli.
|
|
|
|
### commit-with-llm
|
|
|
|
```bash
|
|
printf "$column" 'commit-with-llm' '' 'Commit with llm generated commit message.'
|
|
```
|
|
|
|
### update-with-llm
|
|
|
|
```bash
|
|
printf "$column" 'update-with-llm' '[glob][prompt]' 'Feed files matching glob to LLM and apply changes.'
|
|
```
|
|
|
|
## Logging
|
|
|
|
Colorful logging in task commands.
|
|
|
|
### log-error
|
|
|
|
```bash
|
|
printf "$column" 'log-error' '' 'Colored output for errors.'
|
|
```
|
|
|
|
### log-success
|
|
|
|
```bash
|
|
printf "$column" 'log-success' '' 'Colored output for success.'
|
|
```
|
|
|
|
### log-warning
|
|
|
|
```bash
|
|
printf "$column" 'log-warning' '' 'Colored output for warnings.'
|
|
```
|
|
|
|
## Git
|
|
|
|
Manage git folders and submodules.
|
|
|
|
### commit-git-folder
|
|
|
|
```bash
|
|
printf "$column" 'commit-git-folder' '[message][path]' 'Commit all changes in git folders in path.'
|
|
```
|
|
|
|
### commit-git-folder
|
|
|
|
```bash
|
|
printf "$column" 'clean-git-folder' '' 'Clean git folder.'
|
|
```
|
|
|
|
### ls-git-folder
|
|
|
|
```bash
|
|
printf "$column" 'ls-git-folder' '[path]' 'Space separated list of git folders in path.'
|
|
```
|
|
|
|
### push-git-folder
|
|
|
|
```bash
|
|
printf "$column" 'push-git-folder' '' 'Push all git folders in path.'
|
|
```
|
|
|
|
### reset-git-folder
|
|
|
|
```bash
|
|
printf "$column" 'reset-git-folder' '' 'Abort, rebase and reset git folder.'
|
|
```
|
|
|
|
### stage-git-folder
|
|
|
|
```bash
|
|
printf "$column" 'stage-git-folder' '[path]' 'Stage all files in git folders in path.'
|
|
```
|
|
|
|
### status-git-folder
|
|
|
|
```bash
|
|
printf "$column" 'status-git-folder' '[path]' 'Show status of git folders in path.'
|
|
```
|
|
|
|
### update-submodule
|
|
|
|
```bash
|
|
printf "$column" 'update-submodule' '' 'Update git submodules.'
|
|
```
|
|
|
|
|
|
## Pass
|
|
|
|
Load and store secrets from pass.
|
|
|
|
Set path to pass entry.
|
|
|
|
```bash
|
|
PASS_ENTRY=$(echo "env/${PWD##*/}" | tr '[:upper:]' '[:lower:]')
|
|
```
|
|
|
|
### save-dotenv-to-pass
|
|
|
|
```bash
|
|
printf "$column" 'save-dotenv-to-pass' '' 'Store content of .env in pass entry.'
|
|
```
|
|
|
|
### load-dotenv-from-pass
|
|
|
|
```bash
|
|
printf "$column" 'load-dotenv-from-pass' '' 'Restore content to .env from pass entry.'
|
|
```
|
|
|
|
## KeePass
|
|
|
|
Load and store secrets from KeePassXC.
|
|
|
|
Set path to KeePassXC database and entry.
|
|
|
|
```bash
|
|
KEEPASS_DATABASE_FILE="/path/to/database.kdbx"
|
|
KEEPASS_DATABASE_KEY_FILE="/path/to/keepass.key"
|
|
KEEPASS_ENTRY=$(echo "env/${PWD##*/}" | tr '[:upper:]' '[:lower:]')
|
|
```
|
|
|
|
### save-pass-to-keepass
|
|
|
|
```bash
|
|
printf "$column" 'save-pass-to-keepass' '[pass][entry]' 'Store password to KeePass entry.'
|
|
```
|
|
|
|
### get-pass-from-keepass
|
|
|
|
```bash
|
|
printf "$column" 'get-pass-from-keepass' '[entry]' 'Get password from KeePass entry.'
|
|
```
|
|
|
|
### save-dotenv-to-keepass
|
|
|
|
```bash
|
|
printf "$column" 'save-dotenv-to-keepass' '' 'Store content of .env in KeePass entry.'
|
|
```
|
|
|
|
### load-dotenv-from-keepass
|
|
|
|
```bash
|
|
printf "$column" 'load-dotenv-from-keepass' '' 'Restore content to .env from KeePass entry.'
|
|
```
|
|
|
|
## Docker
|
|
|
|
Build and push Docker images.
|
|
|
|
Set Docker env vars.
|
|
|
|
```bash
|
|
BUILDX_PLATFORM="linux/amd64"
|
|
CONTAINER_REGISTRY="janikvonrotz"
|
|
CONTAINER_TAG="python.casa:latest"
|
|
DOCKERFILE="image/Dockerfile"
|
|
DOCKER_CONFIG="$HOME/.docker/$CONTAINER_REGISTRY/"
|
|
```
|
|
|
|
### login-docker
|
|
|
|
```bash
|
|
printf "$column" 'login-docker' '[user][token]' 'Run Docker login and create docker config.'
|
|
```
|
|
|
|
### build-image
|
|
|
|
```bash
|
|
printf "$column" 'build-image' '[output]' 'Build Docker image with buildx.'
|
|
```
|
|
|
|
## Ansible
|
|
|
|
Install scripts from the Ansible Build project.
|
|
|
|
### install-ansible-build-scripts
|
|
|
|
The available roles with scripts are listed here: <https://ansible.build/scripts.html>
|
|
|
|
```bash
|
|
printf "$column" 'install-ansible-build-scripts' '[role]' 'Install scripts of the specified Ansbile role.'
|
|
```
|