~kris/dots

srice

ref: 9f828eb14bdd54d2c4fd8a3b2c90253021df3152 srice/.local/bin/srht-new -rwxr-xr-x 956 bytes
9f828eb1 — Kris Yotam mksh: backslash-escape commands in history hook to bypass module aliases (wc=tokei, tr=transmission-remote, cat=bat) 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
# srht-new -- create a new sr.ht project (repo + optional tracker + list)
set -eu

if [ -z "${1:-}" ]; then
    echo "Usage: srht-new <name> [description]" >&2
    exit 1
fi

NAME="$1"
DESC="${2:-$NAME}"
TOKEN=$(cat ~/.config/srht/token)

echo "[*] Creating repo: $NAME"
curl -s --oauth2-bearer "$TOKEN" -H 'Content-Type: application/json' \
  -d "{\"query\": \"mutation { createRepository(name: \\\"$NAME\\\", visibility: PRIVATE, description: \\\"$DESC\\\") { id name } }\"}" \
  https://git.sr.ht/query | jq -r '.data.createRepository | "    id: \(.id), name: \(.name)"'

echo "[*] Creating tracker: $NAME"
curl -s --oauth2-bearer "$TOKEN" -H 'Content-Type: application/json' \
  -d "{\"query\": \"mutation { createTracker(name: \\\"$NAME\\\", visibility: PRIVATE) { id name } }\"}" \
  https://todo.sr.ht/query | jq -r '.data.createTracker | "    id: \(.id), name: \(.name)"'

echo "[+] Done. Clone: git clone git@git.sr.ht:~krisyotam/$NAME"