Created
July 2, 2023 06:23
-
-
Save Weiyuan-Lane/29ac79b0abbe81886615bedc552d62f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TMP_DIR=".tmp" | |
mkdir -p $TMP_DIR | |
promptGCPEntry(){ | |
local _gcpIDCacheFilename="$TMP_DIR/gcpprojectid" | |
if [ -e $_gcpIDCacheFilename ]; then | |
gcpProjectId=`cat $_gcpIDCacheFilename` | |
echo "You previously inputted GCP Project ID as \"$gcpProjectId\"" | |
while true; do | |
read -p "Use the same project id? (Y/n): " _reuseCacheDecision | |
case $_reuseCacheDecision in | |
Y|y ) echo ""; return 0;; | |
N|n ) break;; | |
* ) echo "Please input a valid value.";; | |
esac | |
done | |
fi | |
while true; do | |
read -p "Please input your Google Cloud Platform Project ID: " gcpProjectId | |
case $gcpProjectId in | |
"") echo "Please input a valid value.";; | |
* ) echo $gcpProjectId > $_gcpIDCacheFilename; break;; | |
esac | |
done | |
echo "You inputted GCP Project ID as \"$gcpProjectId\"\n" | |
} | |
promptGCPEntry | |
# Pretend this this doing something productive | |
echo "Running some commands for \"$gcpProjectId\"\n" | |
sleep 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment