Beginning debug/cleanup
This commit is contained in:
@@ -237,8 +237,8 @@ ask_pn() {
|
||||
Make it descriptive and avoid spaces and special characters.
|
||||
Example: ${example_pn}
|
||||
EOF
|
||||
trys=3
|
||||
for ((i=1; i<=$trys; i++)); do # give the user up to 3 tries
|
||||
trys=3 # give the user up to 3 tries to enter a valid project name
|
||||
for ((i=1; i<=trys; i++)); do
|
||||
read -r -p "Enter a new or existing project name ($example_pn): " PROJECT
|
||||
if [[ -z $PROJECT ]]; then
|
||||
PROJECT="$example_pn"
|
||||
@@ -248,6 +248,7 @@ ask_pn() {
|
||||
echo "Retrying ($i of $trys)"
|
||||
fi
|
||||
done
|
||||
[[ -z $PROJECT ]] && exit 1 # TODO eventually switch to return, but treat as fatal for now
|
||||
echo "Using project name: $PROJECT"
|
||||
}
|
||||
debug() { (( DEBUG )) && echo "Debug: $*"; }
|
||||
@@ -1493,23 +1494,15 @@ main() {
|
||||
parse_input "$@" # parse arguments with getopt
|
||||
|
||||
# Prompt user for the PROJECT if we still don't have one
|
||||
if [[ ${#PROJECTS[@]} -eq 0 ]]; then # still allows for environment overrides
|
||||
if [[ ${#PROJECTS[@]} -eq 0 ]]; then
|
||||
ask_pn && PROJECTS+=("$PROJECT")
|
||||
while :; do
|
||||
|| break
|
||||
|
||||
done
|
||||
|
||||
|
||||
fi
|
||||
|
||||
for i in "${!PROJECTS[@]}"; do
|
||||
if ! sanitize_pn "${PROJECTS[i]}"; then
|
||||
echo "Project name ${PROJECTS[i]} is invalid"
|
||||
echo "Enter a replacement"
|
||||
ask_pn
|
||||
sanitize_pn "$PROJECT" || (echo "RTFM"; return 1)
|
||||
PROJECTS[i]="$PROJECT"
|
||||
ask_pn && PROJECTS[i]="$PROJECT"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user