shithub: hell

Download patch

ref: f277ed8879dc4e90f93678b781c23e8e0e3c0144
parent: ebc228579fbf22f53f8fd382264ecf0bf8d47fed
author: penny <penny@limitedideas.org>
date: Tue Aug 12 18:38:26 EDT 2025

Post parameters

--- a/commands.go
+++ b/commands.go
@@ -2,6 +2,8 @@
 
 import (
 	"strings"
+
+	"github.com/google/shlex"
 )
 
 var commands = []string{"examine", "reply", "like", "thread", "open", "preview", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "vim", "import", "pause", "resume", "url"}
@@ -30,7 +32,24 @@
 		if strings.HasPrefix(choice, inputcommand) {
 			command = choice
 			_, arguments, _ = strings.Cut(input, " ")
-			return
+			break
+		}
+	}
+
+	return
+}
+
+func extractInputParameters(input string) (remainder string, parameters [][]string) {
+	args, _ := shlex.Split(input)
+
+	for i, arg := range args {
+		if strings.HasPrefix(arg, "?") {
+			key, val, _ := strings.Cut(arg, "=")
+			key = key[1:]
+			parameters = append(parameters, []string{key, val})
+		} else {
+			remainder = strings.Join(args[i:], " ")
+			break
 		}
 	}
 	return
--- a/format.go
+++ b/format.go
@@ -57,7 +57,7 @@
 			result = append(result, remainder[:width]...)
 			result = append(result, '\n')
 			remainder = remainder[width:] // Consume the hyphen
-		} else if remainder[width-1] != ' '{
+		} else if remainder[width-1] != ' ' {
 			result = append(result, remainder[:width-1]...)
 			result = append(result, '-')
 			remainder = remainder[width-1:]
--- a/main.go
+++ b/main.go
@@ -6,8 +6,8 @@
 	"io"
 	"os"
 	"os/exec"
-	"strings"
 	"strconv"
+	"strings"
 
 	"github.com/mattn/go-mastodon"
 )
--- a/mastodon.go
+++ b/mastodon.go
@@ -78,10 +78,10 @@
 	if err != nil {
 		log.Fatal(err)
 	}
-	
+
 	//clear out the url map
 	hc.urlMap[index] = []string{}
-	
+
 	for node := range doc.Descendants() {
 		if node.Data == "a" && node.Type == html.ElementNode {
 			ismention := false
@@ -107,9 +107,7 @@
 			}
 		}
 	}
-	
 
-
 	//Rip off the HTML body the parser made for us
 	for node := range doc.Descendants() {
 		if node.Data == "body" {
@@ -133,7 +131,7 @@
 		Visibility:  visibility,
 		InReplyToID: replyto,
 	}
-	status, err = postStatusDetailed(posttext, account, client, visibility, toot)
+	status, err = postStatusDetailed(posttext, account, client, toot)
 	return
 }
 
@@ -143,11 +141,30 @@
 		Status:     posttext,
 		Visibility: visibility,
 	}
-	status, err = postStatusDetailed(posttext, account, client, visibility, toot)
+	
+	
+	status, err = postStatusDetailed(posttext, account, client, toot)
 	return
 }
 
-func postStatusDetailed(posttext string, account *account, client mastodon.Client, visibility string, toot mastodon.Toot) (status *mastodon.Status, err error) {
+func postStatusDetailed(posttext string, account *account, client mastodon.Client, toot mastodon.Toot) (status *mastodon.Status, err error) {
+	posttext, hints := extractInputParameters(posttext)
+	toot.Status = posttext
+	
+	for _, arg := range hints {
+		key := arg[0]
+		val := arg[1]
+		switch key {
+			case "unlisted":
+				toot.Visibility = "unlisted"
+			case "subject":
+				if(len(val) > 0) {
+					toot.SpoilerText = val
+				}
+						
+		}
+	}
+	
 	status, err = client.PostStatus(context.Background(), &toot)
 
 	if err != nil {
--