Skip to content
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
11 changes: 11 additions & 0 deletions tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,16 @@ testFragmentStripping()
assertContains "Verify whether 'wcurl' correctly strips #fragments from filenames" "${ret}" '--output document.pdf '
}

testMissingArgumentError()
{
ret=$(${WCURL_CMD} --curl-options 2>&1)
assertFalse "Verify whether 'wcurl' with missing argument exits with an error" "$?"
assertEquals "Verify whether 'wcurl' displays missing argument error for --curl-options" "${ret}" "Option '--curl-options' requires an argument."

ret=$(${WCURL_CMD} -o 2>&1)
assertFalse "Verify whether 'wcurl' with missing argument exits with an error" "$?"
assertEquals "Verify whether 'wcurl' displays missing argument error for -o" "${ret}" "Option '-o' requires an argument."
}

# shellcheck disable=SC1091
. shunit2
6 changes: 6 additions & 0 deletions wcurl
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ while [ -n "${1-}" ]; do
;;

--curl-options)
if [ -z "${2-}" ]; then
error "Option '${1}' requires an argument."
fi
shift
CURL_OPTIONS="${CURL_OPTIONS} ${1}"
;;
Expand All @@ -298,6 +301,9 @@ while [ -n "${1-}" ]; do
;;

-o | -O | --output)
if [ -z "${2-}" ]; then
error "Option '${1}' requires an argument."
fi
shift
HAS_USER_SET_OUTPUT="true"
OUTPUT_PATH="${1}"
Expand Down