A => LICENSE +6 -0
@@ 1,6 @@
+EVERYTHING UNDER THIS LICENSE IS PLACED INTO THE PUBLIC DOMAIN
+ALL COPYRIGHTS (AND BY EXTENSION THEIR RESTRICTIONS) ARE HEREBY REVOKED
+
+IN JURISDICTIONS THAT DO NOT ALLOW YOU TO REVOKE COPYRIGHT, USE THESE AS THE CONDITIONS:
+- THERE ARE NO RESTRICTIONS
+- YOU CAN LITERALLY DO WHATEVER YOU WANT
A => README.md +101 -0
@@ 1,101 @@
+# srht
+
+A WIP CLI for sourcehut, using it's official API.
+
+You will need to general a personal access token at https://meta.sr.ht/oauth2<br>
+and set the `TOKEN` variable to it.
+
+## Dependencies
+
+- bash
+- curl
+- jq
+- tr
+- xargs
+
+## Usage
+
+First arg should be the site, currently only `git` is supported.
+
+Second arg should be the query, currently only `repos` and `user` is supported.
+
+## Output
+
+`$ ./srht git user`: `~phate`
+
+`$ ./srht git repos`
+
+```
+Project: ppkg
+Description: "Phate's Package Manager, a binary package manger (planned to be hybrid) written in Rust."
+Updated: 2020-12-28T13:43:38Z
+
+Project: rsPhate
+Description: "A discord bot written in Rust."
+Updated: 2020-12-20T05:28:51Z
+
+Project: srht
+Description: "A WIP CLI for sourcehut."
+Updated: 2020-12-01T21:29:10Z
+
+Project: tes-rpc
+Description: "This is a WIP Discord Rich Presence utility for The Elder Scrolls games."
+Updated: 2020-11-27T22:46:32Z
+
+Project: lobsters
+Description: "A WIP CLI for https://lobster.rs."
+Updated: 2020-11-25T09:41:07Z
+
+Project: bc-lyrics
+Description: "A shell script to scrape lyrics from bandcamp using current music from mpd as the query."
+Updated: 2020-11-19T02:36:44Z
+
+Project: musinfo
+Description: "A program written in pure Rust to query music info from mpd and display it in a notification."
+Updated: 2020-11-18T10:05:25Z
+
+Project: mpc-status
+Description: " A program written in Rust which outputs a single line of output with music info from mpd. "
+Updated: 2020-11-16T02:48:56Z
+
+Project: sxhkdrc-mode
+Description: "A WIP major mode for sxhkd's config file because I couldn't find one for it."
+Updated: 2020-11-08T19:49:59Z
+
+Project: rsmpv
+Description: " A controller for mpv, requires ipc to be enabled in mpv. "
+Updated: 2020-11-08T19:48:42Z
+
+Project: rsmpc-gui
+Description: "A GUI (gtk-rs) application for viewing music info and controlling MPD. "
+Updated: 2020-11-08T19:48:23Z
+
+Project: rsmpc
+Description: "mpc, but implemented in Rust."
+Updated: 2020-11-08T19:48:06Z
+
+Project: rsfetch
+Description: "Neofetch alternative in Rust."
+Updated: 2020-11-08T19:47:52Z
+
+Project: pkg
+Description: "A cli frontend to emerge, plus some extra features. Written in Rust."
+Updated: 2020-11-08T19:47:38Z
+
+Project: nixinfo
+Description: " A lib crate for gathering system info such as cpu, distro, environment, kernel, etc in Rust."
+Updated: 2020-11-08T19:47:25Z
+
+Project: mpv-config
+Description: "My mpv configuration."
+Updated: 2020-11-08T19:46:55Z
+
+Project: gzdoom-discordrpc
+Description: "DiscordRPC for GZDoom, written in Rust."
+Updated: 2020-11-08T19:46:09Z
+
+Project: dotfiles
+Description: "My dotfiles for various things. Like bash, vim, emacs, various WMs, and more."
+Updated: 2020-11-08T19:45:05Z
+
+```
A => srht +43 -0
@@ 1,43 @@
+#!/bin/bash
+## Requirements: curl, jq, tr, xargs
+## Usage: srht SITE QUERY
+## SITE = git
+## QUERY = {user,repos}
+## You MUST generate a personal access token at https://meta.sr.ht/oauth2
+## Please set the contents of the TOKEN variable to it
+
+export TOKEN="REPLACEME!"
+
+if [ "$1" = "git" ]; then
+ export SITE="https://git.sr.ht/query"
+fi
+
+if [ "$2" = "user" ]; then
+ export QUERY="{\"query\": \"{ me { canonicalName } }\"}"
+elif [ "$2" = "repos" ]; then
+ export QUERY="{ \"query\": \"{ me { canonicalName repositories { cursor results { name, description, updated } } } } \"}"
+else
+ echo "Sorry, that query isn't supported yet."
+ exit 1
+fi
+
+export CMD="curl -s -H Authorization:\"Bearer $TOKEN\" -d '$QUERY' -H Content-Type:application/json $SITE"
+
+if [ "$2" = "user" ]; then
+ eval "$CMD | jq .data.me.canonicalName | xargs"
+elif [ "$2" = "repos" ]; then
+ export NAMES="$(eval "$CMD" | jq '.data.me.repositories.results[].name' | xargs)"
+ read -a NAMES_ARRAY <<< "$NAMES"
+
+ export DESCRIPTIONS="$(eval "$CMD" | jq '.data.me.repositories.results[].description' | tr '\n' '|')"
+ IFS='|' read -a DESCRIPTIONS_ARRAY <<< "$DESCRIPTIONS"
+
+ export UPDATED="$(eval "$CMD" | jq '.data.me.repositories.results[].updated' | xargs)"
+ read -a UPDATED_ARRAY <<< "$UPDATED"
+
+ paste -d "\n" \
+ <(printf 'Project: %s\n' "${NAMES_ARRAY[@]}") \
+ <(printf 'Description: %s\n' "${DESCRIPTIONS_ARRAY[@]}") \
+ <(printf 'Updated: %s\n' "${UPDATED_ARRAY[@]}") \
+ <(echo -e "\n")
+fi