Tell us what’s happening:
Describe your issue in detail here.
CodeRoad seems to be stuck in a “launching” phase every time I try to open the cloud IDE- hence preventing me from progressing. The issue has persisted through repeated closing and reopening of CodeRoad via the command palette, and occasionally it does not even show that, leaving me with a black box. Both screenshots are attached. I tried attaching the screenshot of the black box, but am not permitted to.
Your code so far
#!/bin/bash
PSQL="psql -X --username=freecodecamp --dbname=bikes --tuples-only -c"
echo -e "\n~~~~~ Bike Rental Shop ~~~~~\n"
MAIN_MENU() {
if [[ $1 ]]
then
echo -e "\n$1"
fi
echo "How may I help you?"
echo -e "\n1. Rent a bike\n2. Return a bike\n3. Exit"
read MAIN_MENU_SELECTION
case $MAIN_MENU_SELECTION in
1) RENT_MENU ;;
2) RETURN_MENU ;;
3) EXIT ;;
*) MAIN_MENU "Please enter a valid option." ;;
esac
}
RENT_MENU() {
# get available bikes
AVAILABLE_BIKES=$($PSQL "SELECT bike_id, type, size FROM bikes WHERE available = true ORDER BY bike_id")
# if no bikes available
if [[ -z $AVAILABLE_BIKES ]]
then
# send to main menu
MAIN_MENU "Sorry, we don't have any bikes available right now."
else
# display available bikes
echo -e "\nHere are the bikes we have available:"
echo "$AVAILABLE_BIKES" | while read BIKE_ID BAR TYPE BAR SIZE
do
echo "$BIKE_ID) $SIZE\" $TYPE Bike"
done
# ask for bike to rent
echo -e "\nWhich one would you like to rent?"
read BIKE_ID_TO_RENT
# if input is not a number
if [[ ! $BIKE_ID_TO_RENT =~ ^[0-9]+$ ]]
then
# send to main menu
MAIN_MENU "That is not a valid bike number."
else
# get bike availability
# if not available
# send to main menu
fi
fi
}
RETURN_MENU() {
echo "Return Menu"
}
EXIT() {
echo -e "\nThank you for stopping in.\n"
}
MAIN_MENU
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:106.0) Gecko/20100101 Firefox/106.0
Challenge: Learn Bash and SQL by Building a Bike Rental Shop - Build a Bike Rental Shop
Link to the challenge: