diff --git a/TODO.txt b/TODO.txt index 2b57771..c5ffb22 100644 --- a/TODO.txt +++ b/TODO.txt @@ -30,7 +30,7 @@ Milestone: v0.3.0 [x] td [x] tt [ ] http-debug-server - [ ] tp + [x] tp [x] send-patch [x] Log [x] TelodendriaConfig -> Config diff --git a/man/man1/tp.1 b/man/man1/tp.1 new file mode 100644 index 0000000..f2dea09 --- /dev/null +++ b/man/man1/tp.1 @@ -0,0 +1,63 @@ +.Dd $Mdocdate: April 29 2023 $ +.Dt TP 1 +.Os Telodendria Project +.Sh NAME +.Nm tp +.Nd Manage the official patch queue. +.Sh SYNOPSIS +.Np +.Op action +.Op patch +.Sh DESCRIPTION +.Pp +This script is probably not going to be very useful for anyone other +than the official project managers, but for completeness, this page +documents it. +.Pp +.Nm +is a simple script that is used to manage the patch queue. It offers a +simple way to fetch patches from the patch Matrix room and queue them +in a patch directory, which is then updated as patches are handled. +Contributions to Telodendria are entirely patch-based, so this script +makes dealing with patch files much more convenient. +.Pp +.Nm +doesn't implement a complex command line interface. It simply takes an +action as the first argument, and a patch file ID as the second +argument to some actions. The actions are as follows: +.Bl -tag -width Ds +.It ingress +Download all new patches from the patches room. This action is intended +to be called periodically from +.Xr cron 8 +to fetch new patches. +.It queue +List all the patches in the queue, printing the first three lines of +each one so they can be easily identified. +.It view +View the specified patch. Note that the specified patch must be in +the queue. Once it is applied or rejected, this script offers no +facility for viewing it. +.It apply +Apply the specified patch to the current working directory. +.It reverse +Reverse the specified patch on the current working directory. +.It accept|reject +Accept or reject the specified patch by moving it to the appropriate +directory. These actions also prompt for a message, into which it is +expected that an explanation for why the patch was accepted or rejected +will be placed. +.El +.Sh ENVIRONMENT +.Pp +The following environment variables are read by the +.Nm +script: +.Bl -tag -width Ds +.It Ev TELODENDRIA_PUB +The base directory inside which the patch directory relies. +.It Ev HOMESERVER +The Matrix homeserver to contact for receiving patches. +.It Ev ACCESS_TOKEN +The access token to use to authenticate with the Matrix homeserver. +.El diff --git a/man/man1/tt.1 b/man/man1/tt.1 new file mode 100644 index 0000000..3b83bf5 --- /dev/null +++ b/man/man1/tt.1 @@ -0,0 +1,34 @@ +.Dd $Mdocdate: April 29 2023 $ +.Dt TT 1 +.Os Telodendria Project +.Sh NAME +.Nm tt +.Nd Make authenticated Matrix requests. +.Sh SYNPOSIS +.Nm +.Op request-path +.Sh DESCRIPTION +.Nm +is an extremely simple wrapper over +.Xr http 1 +and +.Xr json 1 +that automatically registers a user and continues to log in as that +user. It obtains an access token that it uses to authenticate the +given request, and then logs out when the request has completed. It +also doesn't require the whole URL to be typed; only the path name +is needed. +.Sh ENVIRONMENT +.Bl -tag +.It Ev METH +The request method to use for the user-specified request. +.It Ev DATA +The data to pass to +.Xr http 1 . +This can either be a string, or a file. Consult the +.Xr http 1 +page for details. +.El +.Sh SEE ALSO +.Xr http 1 , +.Xr json 1 diff --git a/tools/bin/tp b/tools/bin/tp index d0e069c..06b2295 100755 --- a/tools/bin/tp +++ b/tools/bin/tp @@ -13,8 +13,6 @@ fi TP_DIR="$TELODENDRIA_PUB/patches" -CURL="curl -s" - if [ ! -d "$TP_DIR" ]; then echo "$TP_DIR does not exist." exit 1 @@ -32,14 +30,14 @@ matrix_send() { printf ',"format":"org.matrix.custom.html",' printf '"msgtype":"m.text"' printf '}' - ) | $CURL -X PUT -d @- "$HOMESERVER/client/v3/rooms/$PATCHES_ROOM/send/m.room.message/$(date +%s)?access_token=$ACCESS_TOKEN" + ) | http -X PUT -d @- "$HOMESERVER/client/v3/rooms/$PATCHES_ROOM/send/m.room.message/$(date +%s)?access_token=$ACCESS_TOKEN" fi } case "$1" in "ingress") timeline="/tmp/timeline.json" - $CURL "$HOMESERVER/client/v3/sync?access_token=$ACCESS_TOKEN" | + http "$HOMESERVER/client/v3/sync?access_token=$ACCESS_TOKEN" | json -s "rooms->join->${PATCHES_ROOM}->timeline" >"$timeline" length=$(cat "$timeline" | json -s "events->@length") @@ -74,7 +72,7 @@ case "$1" in server=$(echo "$url" | cut -d '/' -f 3) - if ! $CURL -o "$TP_DIR/ingress/$id.patch" "$HOMESERVER/media/v3/download/$server/$id"; then + if ! http "$HOMESERVER/media/v3/download/$server/$id" > "$TP_DIR/ingress/$id.patch"; then rm "$TP_DIR/ingress/$id.patch" echo "Failed to fetch mxc://$server/$id." echo "Will try again next time."