Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidies tput formatting, adds check for app.py to http-server wrapper #184

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions opt/cs50/bin/http-server
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ port="-p 8080"
options="--no-dotfiles"
t="-t0"

# Formatting
bold=$(tput bold)
normal=$(tput sgr0)

# Check for app.py or wsgi.py
rongxin-liu marked this conversation as resolved.
Show resolved Hide resolved
if [[ -f app.py ]] || [[ -f wsgi.py ]]; then
read -p "Are you sure you want to run ${bold}http-server${normal} and not ${bold}flask${normal}? [y/N] " -r
if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then
exit 1
fi
fi

# Override default options
while test ${#} -gt 0
do
Expand Down
10 changes: 7 additions & 3 deletions opt/cs50/bin/sqlite3
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# Formatting
bold=$(tput bold)
normal=$(tput sgr0)

# If data is coming from stdin (pipe or redirection)
if [[ -p /dev/stdin || ! -t 0 ]]; then
/usr/local/bin/sqlite3 -nullvalue NULL -table "$@" < /dev/stdin
Expand All @@ -8,7 +12,7 @@ fi

# If no command-line argument
if [[ $# -eq 0 ]]; then
read -p "Are you sure you want to run $(tput bold)sqlite3$(tput sgr0) without a command-line argument (e.g., the filename of a database)? [y/N] " -r
read -p "Are you sure you want to run ${bold}sqlite3${normal} without a command-line argument (e.g., the filename of a database)? [y/N] " -r
if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then
exit 1
fi
Expand All @@ -17,12 +21,12 @@ if [[ $# -eq 0 ]]; then
elif [[ $# -eq 1 ]] && [[ ! "$1" =~ ^- ]]; then
if [[ ! -f "$1" ]]; then
if [[ ! "$1" =~ \.db$ ]]; then
read -p "Are you sure you want to create $(tput bold)$1$(tput sgr0)? SQLite filenames usually end in $(tput bold).db$(tput sgr0). [y/N] " -r
read -p "Are you sure you want to create ${bold}$1${normal}? SQLite filenames usually end in ${bold}.db${normal}. [y/N] " -r
if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then
exit 1
fi
else
read -p "Are you sure you want to create $(tput bold)$1$(tput sgr0)? [y/N] " -r
read -p "Are you sure you want to create ${bold}$1${normal}? [y/N] " -r
if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then
exit 1
fi
Expand Down
Loading