refactor: reorganise bash scripts into subdirectories and add bash runner support

Move yubikey scripts from bash/ root into bash/yubikey/, move cohort shell
scripts from python/cohort/ into bash/cohort/, and update run.sh to support
Bash as a third language with category-based script discovery.
This commit is contained in:
2026-02-23 20:00:44 -08:00
committed by Naomi Carrigan
parent c4b9f795d9
commit b0620f2af3
6 changed files with 16 additions and 12 deletions
+16 -12
View File
@@ -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"