diff --git a/bin/upload-jmespath b/bin/upload-jmespath new file mode 100755 index 0000000..c7be576 --- /dev/null +++ b/bin/upload-jmespath @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -euo pipefail + +API_URL="https://jmespath-playground.koszewscy.waw.pl" +JSON_FILE="-" + +function usage() { + echo "Usage: $0 [--api-url ] [--json-file ]" + exit 1 +} + +while [[ $# -gt 0 ]]; do + case $1 in + --api-url) + API_URL="$2" + shift 2 + ;; + --json-file) + JSON_FILE="$2" + shift 2 + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "ERROR: Unknown argument: $1" + usage + exit 1 + ;; + esac +done + +# Send the POST request +curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + --data @${JSON_FILE} \ + "$API_URL/api/v1/upload" +