feat: print response code to CLI (#10)

Closes #8

Reviewed-on: https://codeberg.org/vlw/curl/pulls/10
Co-authored-by: vlw <victor@vlw.se>
Co-committed-by: vlw <victor@vlw.se>
This commit is contained in:
Victor Westerlund 2026-04-06 10:25:27 +02:00 committed by Victor Westerlund
parent 328cebc703
commit e015174467
2 changed files with 5 additions and 2 deletions

View file

@ -1,4 +1,4 @@
![screenshot](https://codeberg.org/attachments/1cae98c6-0873-41fd-aad0-d33bf495fc50)
![curl-screenshot](https://codeberg.org/attachments/9bdd8005-5eea-4add-89c3-8efc61d06b6f)
![license](https://licensebuttons.net/p/zero/1.0/88x31.png)

View file

@ -66,8 +66,11 @@ curl_cmd="$curl_cmd -o $RESP_BODY_RAW_FILE -D $RESP_HEADERS_FILE"
# Execute curl
eval "clear"
echo -e "${method} ${url}"
echo -e "\e[0;92mRequest >\e[0m ${method} ${url}"
eval $curl_cmd
# Copy the raw respone body to a pretty-printed JSON file
jq . $RESP_BODY_RAW_FILE > $RESP_BODY_JSON_FILE
# Print the response code
echo -e -n "\e[0;94mResponse <\e[0m "; awk 'NR==1{print $2, $3; exit}' $RESP_HEADERS_FILE