generated from nhcarrigan/template
feat: reorganise bash scripts and add comprehensive documentation #6
@@ -96,7 +96,7 @@ select_option() {
|
|||||||
|
|
||||||
# Step 1: Select Language
|
# Step 1: Select Language
|
||||||
echo ""
|
echo ""
|
||||||
languages=("TypeScript" "Python")
|
languages=("TypeScript" "Python" "Bash")
|
||||||
select_option "Select a language:" "${languages[@]}"
|
select_option "Select a language:" "${languages[@]}"
|
||||||
lang_index=$?
|
lang_index=$?
|
||||||
language="${languages[$lang_index]}"
|
language="${languages[$lang_index]}"
|
||||||
@@ -109,15 +109,16 @@ if [ "$language" == "TypeScript" ]; then
|
|||||||
runner="pnpm tsx"
|
runner="pnpm tsx"
|
||||||
# Get subdirectories as categories (excluding utils and interfaces)
|
# Get subdirectories as categories (excluding utils and interfaces)
|
||||||
mapfile -t categories < <(find "$script_dir" -mindepth 1 -maxdepth 1 -type d ! -name 'utils' ! -name 'interfaces' -exec basename {} \; | sort)
|
mapfile -t categories < <(find "$script_dir" -mindepth 1 -maxdepth 1 -type d ! -name 'utils' ! -name 'interfaces' -exec basename {} \; | sort)
|
||||||
else
|
elif [ "$language" == "Python" ]; then
|
||||||
script_dir="python"
|
script_dir="python"
|
||||||
runner="uv run python"
|
runner="uv run python"
|
||||||
# Get subdirectories as categories (excluding __pycache__ and .venv)
|
# Get subdirectories as categories (excluding __pycache__ and .venv)
|
||||||
mapfile -t categories < <(find "$script_dir" -mindepth 1 -maxdepth 1 -type d ! -name '__pycache__' ! -name '.venv' ! -name '*.egg-info' -exec basename {} \; | sort)
|
mapfile -t categories < <(find "$script_dir" -mindepth 1 -maxdepth 1 -type d ! -name '__pycache__' ! -name '.venv' ! -name '*.egg-info' -exec basename {} \; | sort)
|
||||||
# Add "Root Scripts" option for Python files in root
|
else
|
||||||
if ls "$script_dir"/*.py &>/dev/null 2>&1; then
|
script_dir="bash"
|
||||||
categories=("Root Scripts" "${categories[@]}")
|
runner="bash"
|
||||||
fi
|
# Get subdirectories as categories
|
||||||
|
mapfile -t categories < <(find "$script_dir" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${#categories[@]} -eq 0 ]; then
|
if [ ${#categories[@]} -eq 0 ]; then
|
||||||
@@ -132,12 +133,12 @@ category="${categories[$cat_index]}"
|
|||||||
echo -e "\n ${GREEN}$STAR Selected: ${WHITE}$category${RESET}\n"
|
echo -e "\n ${GREEN}$STAR Selected: ${WHITE}$category${RESET}\n"
|
||||||
|
|
||||||
# Step 3: Get scripts in category
|
# Step 3: Get scripts in category
|
||||||
if [ "$category" == "Root Scripts" ]; then
|
if [ "$language" == "TypeScript" ]; then
|
||||||
search_dir="$script_dir"
|
|
||||||
mapfile -t scripts < <(find "$search_dir" -maxdepth 1 -name "*.py" -exec basename {} \; | sort)
|
|
||||||
elif [ "$language" == "TypeScript" ]; then
|
|
||||||
search_dir="$script_dir/$category"
|
search_dir="$script_dir/$category"
|
||||||
mapfile -t scripts < <(find "$search_dir" -name "*.ts" -exec basename {} \; | sort)
|
mapfile -t scripts < <(find "$search_dir" -name "*.ts" -exec basename {} \; | sort)
|
||||||
|
elif [ "$language" == "Bash" ]; then
|
||||||
|
search_dir="$script_dir/$category"
|
||||||
|
mapfile -t scripts < <(find "$search_dir" -name "*.sh" -exec basename {} \; | sort)
|
||||||
else
|
else
|
||||||
search_dir="$script_dir/$category"
|
search_dir="$script_dir/$category"
|
||||||
mapfile -t scripts < <(find "$search_dir" -name "*.py" ! -name "__init__.py" -exec basename {} \; | sort)
|
mapfile -t scripts < <(find "$search_dir" -name "*.py" ! -name "__init__.py" -exec basename {} \; | sort)
|
||||||
@@ -155,8 +156,8 @@ script="${scripts[$script_index]}"
|
|||||||
echo -e "\n ${GREEN}$STAR Selected: ${WHITE}$script${RESET}\n"
|
echo -e "\n ${GREEN}$STAR Selected: ${WHITE}$script${RESET}\n"
|
||||||
|
|
||||||
# Build the full script path
|
# Build the full script path
|
||||||
if [ "$category" == "Root Scripts" ]; then
|
if [ "$language" == "Bash" ]; then
|
||||||
script_path="$script"
|
script_path="bash/$category/$script"
|
||||||
elif [ "$language" == "TypeScript" ]; then
|
elif [ "$language" == "TypeScript" ]; then
|
||||||
script_path="src/$category/$script"
|
script_path="src/$category/$script"
|
||||||
else
|
else
|
||||||
@@ -178,6 +179,9 @@ if [ "$language" == "TypeScript" ]; then
|
|||||||
cd typescript
|
cd typescript
|
||||||
echo -e " ${DIM}$ op run --env-file=../prod.env -- $runner $script_path${RESET}\n"
|
echo -e " ${DIM}$ op run --env-file=../prod.env -- $runner $script_path${RESET}\n"
|
||||||
op run --env-file=../prod.env --no-masking -- $runner "$script_path"
|
op run --env-file=../prod.env --no-masking -- $runner "$script_path"
|
||||||
|
elif [ "$language" == "Bash" ]; then
|
||||||
|
echo -e " ${DIM}$ $runner $script_path${RESET}\n"
|
||||||
|
$runner "$script_path"
|
||||||
else
|
else
|
||||||
cd python
|
cd python
|
||||||
echo -e " ${DIM}$ op run --env-file=../prod.env -- $runner $script_path${RESET}\n"
|
echo -e " ${DIM}$ op run --env-file=../prod.env -- $runner $script_path${RESET}\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user