Skip to content

Commit

Permalink
Improve util script path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bkis committed Jul 3, 2024
1 parent 71f5754 commit 6720146
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Tekst-Util/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This Bash script simplifies performing common maintenance tasks (backup/restore

## Usage

> **IMPORTANT:** The script assumes it's located inside `/<path-to-Tekst-repo>/Tekst-Util/`, so **do not move it anywhere else!**!
Run `./tekst-util --help` for an overview of the commands, flags and arguments. Each command has its own help that can be accessed via `./tekst-util <command> --help`.

## Development
Expand Down
3 changes: 2 additions & 1 deletion Tekst-Util/src/index_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dev=${args[--dev]}
if [[ $container ]]; then
docker exec -e TEKST_DEV_MODE=$dev -i $container $run_python -m tekst index
else
cd Tekst-API
cd_to_script_parent_dir
cd ../Tekst-API
TEKST_DEV_MODE=$dev $run_python -m tekst index
fi
4 changes: 4 additions & 0 deletions Tekst-Util/src/lib/fnc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cd_to_script_parent_dir() {
script_parent_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$script_parent_dir"
}
10 changes: 9 additions & 1 deletion Tekst-Util/tekst-util
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ inspect_args() {
fi
}

# :command.user_lib
# src/lib/fnc.sh
cd_to_script_parent_dir() {
script_parent_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$script_parent_dir"
}

# :command.command_functions
# :command.function
tekst_util_backup_command() {
Expand Down Expand Up @@ -346,7 +353,8 @@ tekst_util_index_command() {
if [[ $container ]]; then
docker exec -e TEKST_DEV_MODE=$dev -i $container $run_python -m tekst index
else
cd Tekst-API
cd_to_script_parent_dir
cd ../Tekst-API
TEKST_DEV_MODE=$dev $run_python -m tekst index
fi

Expand Down

0 comments on commit 6720146

Please sign in to comment.