1
0
mirror of https://github.com/jaygooby/ttfb.sh synced 2025-12-10 16:07:22 +01:00

show usage when script is called without arguments

Fixes https://github.com/jaygooby/ttfb.sh/issues/6
This commit is contained in:
Daniel Abromeit aka Abro
2021-07-02 20:05:41 +02:00
committed by GitHub
parent 07bfb15adf
commit b7b0d474eb

10
ttfb
View File

@@ -91,6 +91,10 @@ median() {
echo $val
}
show_usage() {
echo -e "Usage: ttfb [options] url [url...]\n\t-d debug\n\t-l <log file> (infers -d) log response headers. Defaults to ./curl.log\n\t-n <number> of times to test time to first byte\n\t-v verbose output. Show response breakdown (DNS lookup, TLS handshake etc)" >&2
}
# defaults
DEBUG=""
LOG=""
@@ -104,7 +108,7 @@ do
l) LOG="$OPTARG" ;;
n) NUM_REQUESTS=$OPTARG ;;
v) VERBOSE=1 ;;
\?) echo -e "Usage: ttfb [options] url [url...]\n\t-d debug\n\t-l <log file> (infers -d) log response headers. Defaults to ./curl.log\n\t-n <number> of times to test time to first byte\n\t-v verbose output. Show response breakdown (DNS lookup, TLS handshake etc)" >&2
\?) show_usage
exit 1
;;
esac
@@ -113,8 +117,8 @@ done
shift $((OPTIND - 1)) # shifts away every option argument,
# leaving urls as $@
if [ -z "$1" ]; then
echo "You didn't specify any urls to fetch"
if [ -z "${1:-}" ]; then
show_usage
exit 1
else
URLS="$@"