diff --git a/PKGBUILD b/PKGBUILD index 68df20f..6941215 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -2,7 +2,7 @@ #Well, it seems to work now. pkgname=clemmy -pkgver=0.1.6 +pkgver=0.1.7 pkgrel=1 pkgdesc='A pure bash client for lemmy, with multiaccount support.' arch=('any') diff --git a/clemmy.sh b/clemmy.sh index fd55eac..f7ed288 100755 --- a/clemmy.sh +++ b/clemmy.sh @@ -12,7 +12,7 @@ while getopts "a:hi:v" o;do case "${o}" in a) select_account $OPTARG;; i) INSTANCE=$OPTARG;; h) echo $actions; exit;; - v) echo 0.1.4; exit;; + v) echo 0.1.7; exit;; esac done shift $((OPTIND-1)) diff --git a/commands/communities.sh b/commands/communities.sh index 4742b1b..f29ca4f 100644 --- a/commands/communities.sh +++ b/commands/communities.sh @@ -1,7 +1,7 @@ #Community hoardan follow(){ post "community/follow" '{"community_id":'$1',"follow":true}'; } unfollow(){ post "community/follow" '{"community_id":'$1',"follow":false}'; } -following(){ echo "use instead"; } # Maybe this will help. +following(){ getauth "community/list" ".communities | $communities_jq" "type_=Subscribed"; } # Alright it's time comcreate(){ namedget desc "The community's display name (can be edited later)"; post "community" '{"name":"'$1'","title":"'"$desc"'"}'; } comedit(){ echo "stub"; } diff --git a/commands/lurking.sh b/commands/lurking.sh index 3996b00..03ab8a3 100644 --- a/commands/lurking.sh +++ b/commands/lurking.sh @@ -1,7 +1,7 @@ #Lurkan -notifs(){ getauth "user/replies" ".replies | reverse | $notifs"; } +notifs(){ getauth "user/replies" ".replies | reverse | $notifs_jq"; } notifs2(){ echo "use mentions instead"; } -mentions(){ getauth "user/mention" ".mentions | reverse | $notifs"; } -home(){ getauth "post/list" ".posts | $posts" "type_=Subscribed"; } +mentions(){ getauth "user/mention" ".mentions | reverse | $notifs_jq"; } +home(){ getauth "post/list" ".posts | $posts_jq" "type_=Subscribed"; } #This has to get complex now -.- -comments(){ getauth "post" "(.post_view | $showpost)" "id=$1"; getauth "comment/list" "(.comments | reverse | $comments_view)" "post_id=$1&sort=New"; } +comments(){ getauth "post" "(.post_view | $full_post_jq)" "id=$1"; getauth "comment/list" "(.comments | reverse | $comments_jq)" "post_id=$1&sort=New"; } diff --git a/commands/posts.sh b/commands/posts.sh index 7a663e3..c2a9b91 100644 --- a/commands/posts.sh +++ b/commands/posts.sh @@ -1,7 +1,7 @@ #Post hoardan save(){ put "post/save" '{"post_id":'$1',"save":true}'; } unsave(){ put "post/save" '{"post_id":'$1',"save":false}'; } -load(){ getauth "post/list" ".posts | .[] | $postsummary" "type_=All&saved_only=true"; } +load(){ getauth "post/list" ".posts | .[] | $short_post_jq" "type_=All&saved_only=true"; } #Postan freepost(){ getbody; post "post" '{"community_id":'$1',"name":"'${*:2}'","body":"'$body'"}'; } shitpost(){ getbody; postid=$1; parentid=$2; if [ -z $parentid ]; then parentid=null; fi; post "comment" '{"post_id":'$postid',"parent_id":'$parentid',"content":"'$body'"}'; } \ No newline at end of file diff --git a/pretty.sh b/pretty.sh index ad9f5e8..2e85ca2 100644 --- a/pretty.sh +++ b/pretty.sh @@ -1,23 +1,24 @@ # Please don't abuse jq like this -showpost='(.post | (.id | tostring)+" "+(.name | tostring)), +full_post_jq='(.post | (.id | tostring)+" "+(.name | tostring)), (.post.url)+", "+(.creator.display_name // .creator.name)+":", ((.comment // .post) | .published, -(.body // .content)), -""' -postsummary='(.post | (.id | tostring)+" "+(.name | tostring)), +(.body // .content))' +short_post_jq='(.post | (.id | tostring)+" "+(.name | tostring)), (.post.url)+", "+(.creator.display_name // .creator.name)+":", -((.comment // .post) | .published), -""' -showcomment='(.comment | .path[2:])+", "+(.creator.display_name // .creator.name)+":", +((.comment // .post) | .published)' +comment_jq='(.comment | .path[2:])+", "+(.creator.display_name // .creator.name)+":", ((.comment // .post) | .published, -(.body // .content)), -""' +(.body // .content))' #Split this out because I specifically do want to include post IDs in some places. Or rather, I only don't want to include them on the comments view. -notif='(.comment | (.parent_id | tostring)+"->"+(.id | tostring))+" ("+(.post | (.id | tostring))+"), "+(.creator.display_name // .creator.name)+":", +notif_jq='(.comment | (.parent_id | tostring)+"->"+(.id | tostring))+" ("+(.post | (.id | tostring))+"), "+(.creator.display_name // .creator.name)+":", ((.comment // .post) | .published, -(.body // .content)), -""' +(.body // .content))' +community_jq='(.community | (.id | tostring)+" "+.actor_id,.description), +.subscribed, +(.counts | [.subscribers,.posts,.comments,.users_active_week] | join(" "))' -comments_view=".[] | $showcomment" -posts=".[] | $showpost" -notifs=".[] | $notif" +multi_jq(){ echo '.[] | '"$1"',""'; } +comments_jq=$(multi_jq "$comment_jq") +posts_jq=$(multi_jq "$full_post_jq") +notifs_jq=$(multi_jq "$notif_jq") +communities_jq=$(multi_jq "$community_jq") \ No newline at end of file