#!/usr/bin/env bash # scripts/add-item.sh — quick add via Gum. # Requires: gum, jq, curl. Token at ~/.${APP_SLUG}rc.json. set -euo pipefail : "${APP_BASE:=http://localhost:3000}" : "${APP_SLUG:=app}" CONFIG="$HOME/.${APP_SLUG}rc.json" if [ ! -f "$CONFIG" ]; then gum style --foreground 196 "No token. Get one at $APP_BASE/settings/tokens and save to $CONFIG" exit 1 fi TOKEN=$(jq -r .token "$CONFIG") TITLE=$(gum input --placeholder "Title") [ -z "$TITLE" ] && exit 0 gum spin --spinner dot --title "Saving…" -- \ curl -sf -X POST "$APP_BASE/api/items" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d "$(jq -n --arg t "$TITLE" '{title:$t}')" gum style --foreground 212 "Added: $TITLE"