update_bead.sh: add reparent support via --field parent

This commit is contained in:
Levi Neely 2026-03-20 14:08:25 +01:00
parent ed94458282
commit d70162ad13
1 changed files with 18 additions and 2 deletions

View File

@ -25,5 +25,21 @@ if [ -z "$MOUNT" ] || [ -z "$BEAD_ID" ] || [ -z "$FIELD" ]; then
exit 1
fi
printf "update %s %s '%s'\n" "$BEAD_ID" "$FIELD" "$VALUE" | 9p write anvillm/beads/$MOUNT/ctl
echo "updated $BEAD_ID.$FIELD: $VALUE"
if [ "$FIELD" = "parent" ]; then
# Reparent: create new bead under parent with same data, then delete original
JSON=$(9p read "anvillm/beads/$MOUNT/$BEAD_ID/json")
TITLE=$(echo "$JSON" | jq -r '.title')
DESC=$(echo "$JSON" | jq -r '.description // ""')
STATUS=$(echo "$JSON" | jq -r '.status')
# Create under new parent
printf "new '%s' '%s' %s\n" "$TITLE" "$DESC" "$VALUE" | 9p write anvillm/beads/$MOUNT/ctl
# Delete original
printf "delete %s\n" "$BEAD_ID" | 9p write anvillm/beads/$MOUNT/ctl
echo "reparented $BEAD_ID under $VALUE"
else
printf "update %s %s '%s'\n" "$BEAD_ID" "$FIELD" "$VALUE" | 9p write anvillm/beads/$MOUNT/ctl
echo "updated $BEAD_ID.$FIELD: $VALUE"
fi