31 lines
1.2 KiB
Bash
Executable File
31 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# wq_project_update — update a project (name or external_ref)
|
|
# Usage: wq project update <project_id> [--name <name>] [--external-ref <ref>]
|
|
|
|
API_URL="${WORK_QUEUE_API_URL:-}"
|
|
[[ -z "$API_URL" ]] && API_URL=$(cat ~/.config/work_queue_api_url 2>/dev/null || echo "")
|
|
[[ -z "$API_URL" ]] && { echo "Error: WORK_QUEUE_API_URL not set" >&2; exit 1; }
|
|
|
|
project_id="" name="" external_ref=""
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--name) name="$2"; shift 2;;
|
|
--external-ref) external_ref="$2"; shift 2;;
|
|
--) shift; break;;
|
|
-*) echo "Unknown option: $1" >&2; exit 1;;
|
|
*) [[ -z "$project_id" ]] && project_id="$1"; shift;;
|
|
esac
|
|
done
|
|
|
|
[[ -z "$project_id" ]] && { echo "Usage: wq project update <project_id> [--name <name>] [--external-ref <ref>]" >&2; exit 1; }
|
|
[[ -z "$name" ]] && [[ -z "$external_ref" ]] && { echo "Error: at least one of --name or --external-ref required" >&2; exit 1; }
|
|
|
|
body="{}"
|
|
[[ -n "$name" ]] && body=$(echo "$body" | jq ".name=\"$name\"")
|
|
[[ -n "$external_ref" ]] && body=$(echo "$body" | jq ".external_ref=\"$external_ref\"")
|
|
|
|
curl -sf -X PATCH "$API_URL/projects/$project_id" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$body" | jq .
|