From b0620f2af385f165eff47f72d41c49cb6388b397 Mon Sep 17 00:00:00 2001 From: Hikari Date: Mon, 23 Feb 2026 20:00:44 -0800 Subject: [PATCH] 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. --- .../cohort/remove_github_members.sh | 0 .../cohort/update_github_teams.sh | 0 bash/{ => yubikey}/add-keys-to-git.sh | 0 bash/{ => yubikey}/fix-yubikey-perms.sh | 0 bash/{ => yubikey}/list-yubikey-ssh-keys.sh | 0 run.sh | 28 +++++++++++-------- 6 files changed, 16 insertions(+), 12 deletions(-) rename {python => bash}/cohort/remove_github_members.sh (100%) rename {python => bash}/cohort/update_github_teams.sh (100%) rename bash/{ => yubikey}/add-keys-to-git.sh (100%) rename bash/{ => yubikey}/fix-yubikey-perms.sh (100%) rename bash/{ => yubikey}/list-yubikey-ssh-keys.sh (100%) diff --git a/python/cohort/remove_github_members.sh b/bash/cohort/remove_github_members.sh similarity index 100% rename from python/cohort/remove_github_members.sh rename to bash/cohort/remove_github_members.sh diff --git a/python/cohort/update_github_teams.sh b/bash/cohort/update_github_teams.sh similarity index 100% rename from python/cohort/update_github_teams.sh rename to bash/cohort/update_github_teams.sh diff --git a/bash/add-keys-to-git.sh b/bash/yubikey/add-keys-to-git.sh similarity index 100% rename from bash/add-keys-to-git.sh rename to bash/yubikey/add-keys-to-git.sh diff --git a/bash/fix-yubikey-perms.sh b/bash/yubikey/fix-yubikey-perms.sh similarity index 100% rename from bash/fix-yubikey-perms.sh rename to bash/yubikey/fix-yubikey-perms.sh diff --git a/bash/list-yubikey-ssh-keys.sh b/bash/yubikey/list-yubikey-ssh-keys.sh similarity index 100% rename from bash/list-yubikey-ssh-keys.sh rename to bash/yubikey/list-yubikey-ssh-keys.sh diff --git a/run.sh b/run.sh index 24b6948..7f48294 100755 --- a/run.sh +++ b/run.sh @@ -96,7 +96,7 @@ select_option() { # Step 1: Select Language echo "" -languages=("TypeScript" "Python") +languages=("TypeScript" "Python" "Bash") select_option "Select a language:" "${languages[@]}" lang_index=$? language="${languages[$lang_index]}" @@ -109,15 +109,16 @@ if [ "$language" == "TypeScript" ]; then runner="pnpm tsx" # 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) -else +elif [ "$language" == "Python" ]; then script_dir="python" runner="uv run python" # 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) - # Add "Root Scripts" option for Python files in root - if ls "$script_dir"/*.py &>/dev/null 2>&1; then - categories=("Root Scripts" "${categories[@]}") - fi +else + script_dir="bash" + runner="bash" + # Get subdirectories as categories + mapfile -t categories < <(find "$script_dir" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort) fi if [ ${#categories[@]} -eq 0 ]; then @@ -132,12 +133,12 @@ category="${categories[$cat_index]}" echo -e "\n ${GREEN}$STAR Selected: ${WHITE}$category${RESET}\n" # Step 3: Get scripts in category -if [ "$category" == "Root Scripts" ]; then - search_dir="$script_dir" - mapfile -t scripts < <(find "$search_dir" -maxdepth 1 -name "*.py" -exec basename {} \; | sort) -elif [ "$language" == "TypeScript" ]; then +if [ "$language" == "TypeScript" ]; then search_dir="$script_dir/$category" 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 search_dir="$script_dir/$category" 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" # Build the full script path -if [ "$category" == "Root Scripts" ]; then - script_path="$script" +if [ "$language" == "Bash" ]; then + script_path="bash/$category/$script" elif [ "$language" == "TypeScript" ]; then script_path="src/$category/$script" else @@ -178,6 +179,9 @@ if [ "$language" == "TypeScript" ]; then cd typescript 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" +elif [ "$language" == "Bash" ]; then + echo -e " ${DIM}$ $runner $script_path${RESET}\n" + $runner "$script_path" else cd python echo -e " ${DIM}$ op run --env-file=../prod.env -- $runner $script_path${RESET}\n"