shithub: hell

Download patch

ref: a05810cf18d3025b8a95d8b640e29e0b36a5be2e
parent: 4b66e6993ee9d4e669f9739b16680a15c5e3f6b7
author: penny <penny@limitedideas.org>
date: Wed Oct 1 12:59:28 EDT 2025

change image view command and document it, display config location in /help

--- a/commands.go
+++ b/commands.go
@@ -4,7 +4,7 @@
 	"strings"
 )
 
-var commands = []string{"examine", "reply", "like", "thread", "open", "prev", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "import", "pause", "resume", "url", "fpost", "ufpost", "edit", "notice", "stats", "next", "preview", "bookmarks", "follow", "unfollow", "likes", "help"}
+var commands = []string{"examine", "reply", "like", "thread", "open", "prev", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "import", "pause", "resume", "url", "fpost", "ufpost", "edit", "notice", "stats", "next", "view", "bookmarks", "follow", "unfollow", "likes", "help"}
 
 func processInput(input string) (command string, arguments string, found bool) {
 
--- a/config.go
+++ b/config.go
@@ -78,7 +78,7 @@
 	return *prefs
 }
 
-func loadConfig() (*mastodon_account, error) {
+func loadConfig() (*mastodon_account, string, error) {
 	config := &account_array{}
 	first_account := &mastodon_account{}
 	homedir, err := os.UserHomeDir()
@@ -106,28 +106,28 @@
 		encoder.SetIndentTables(true)
 		err = encoder.Encode(config)
 		if err != nil {
-			return nil, fmt.Errorf("error marshalling config: %w", err)
+			return nil, "", fmt.Errorf("error marshalling config: %w", err)
 		}
 
 		err = ioutil.WriteFile(configpath, b.Bytes(), 0644)
 		if err != nil {
-			return nil, fmt.Errorf("error writing config file: %w", err)
+			return nil, "", fmt.Errorf("error writing config file: %w", err)
 		}
-		return first_account, nil
+		return first_account, "", nil
 	}
 
 	// File exists, load it
 	data, err := ioutil.ReadFile(configpath)
 	if err != nil {
-		return nil, fmt.Errorf("error reading config file: %w", err)
+		return nil, "", fmt.Errorf("error reading config file: %w", err)
 	}
 
 	err = toml.Unmarshal(data, config)
 	if err != nil {
-		return nil, fmt.Errorf("error unmarshalling config: %w", err)
+		return nil, "", fmt.Errorf("error unmarshalling config: %w", err)
 	}
 	if len(config.AccountConfigs) < 1 {
-		return nil, fmt.Errorf("empty config?\n")
+		return nil, "", fmt.Errorf("empty config?\n")
 	}
 
 	prefval := config.AccountConfigs[0].Preferences
@@ -141,16 +141,16 @@
 		encoder.SetIndentTables(true)
 		err = encoder.Encode(config)
 		if err != nil {
-			return nil, fmt.Errorf("error marshalling config: %w", err)
+			return nil, "", fmt.Errorf("error marshalling config: %w", err)
 		}
 
 		err = ioutil.WriteFile(configpath, b.Bytes(), 0644)
 		if err != nil {
-			return nil, fmt.Errorf("error writing config file: %w", err)
+			return nil, "", fmt.Errorf("error writing config file: %w", err)
 		}
 	}
 	prefs.Save_Location = expandDir(prefs.Save_Location)
-	return config.AccountConfigs[0], nil
+	return config.AccountConfigs[0], configpath, nil
 }
 
 func expandDir(dir string) string {
--- a/hellclient.go
+++ b/hellclient.go
@@ -36,6 +36,7 @@
 	recentpost    *mastodon.Status
 	preferences   *Hellprefs
 	multiLineMode bool
+	configPath    string
 
 	//Global status map for status indexes
 	//Needs to be converted to a postref struct
@@ -111,7 +112,7 @@
 		return nil, err
 	}
 
-	account, err := loadConfig()
+	account, configpath, err := loadConfig()
 	if err != nil {
 		return nil, err
 	}
@@ -182,6 +183,7 @@
 		jobdispatch: jobdispatch,
 		preferences: prefs,
 		stats:       &Stats{},
+		configPath:  configpath,
 	}
 	return &hc, nil
 }
--- a/help.go
+++ b/help.go
@@ -1,10 +1,13 @@
 package main
 
-func helpString() string {
-	return `Lines with no command are sent as a post.
+import "fmt"
+
+func helpString(configpath string) string {
+	helpstring := `Lines with no command are sent as a post.
   Most commands that take <index> will operate on the most recently interacted with status,
   if no index is passed.
   Posts with multiple arguments may accept "." to operate on recent status.
+  Config file location: %s
   
   ctrl-j                       Enable and disable multi-line mode
   /help                        Show this help message.
@@ -13,6 +16,8 @@
   /thread <index>              View thread the indexed status is part of.
   /open <index>                Open indexed status in the system web browser.
   /download <index>            Download attached files/media from status.
+  /view <index>                Preview status media in media viewer.
+  /import <index>              Same as /view with an alternative media handler.
   /dm <content>                Create a status with direct visibility (e.g. a dm).
   /rt <index>                  Boost a status by index.
   /parent <index>              View parent of status by index.
@@ -36,10 +41,11 @@
                                If there are none unread, opens notification page.
                              
   /stats                       Print some running stats.
-  /preview <index>             Open attached media in system media viewer.
+  /help <index>             Open attached media in system media viewer.
   /bookmarks                   Open bookmarks page.
   /follow [index] [account]    Follow account by post index or name.
   /unfollow [index] [account]  Unfollow account by post index or name.
   /likes                       Display favorited status page.
 `
+return fmt.Sprintf(helpstring, configpath)
 }
--- a/main.go
+++ b/main.go
@@ -103,7 +103,7 @@
 			//Contextual commands that need to handle their own requirements
 			switch command {
 			case "help":
-				fmt.Println(hyphenate(helpString()))
+				fmt.Println(hyphenate(helpString(hc.configPath)))
 				return
 			case "stats":
 				hc.stats.slock.Lock()
@@ -265,7 +265,7 @@
 				}
 				openItemInOS(hc.preferences.Browser, hc.urlMap[index][urlindex-1])
 				return
-			case "preview":
+			case "view":
 				err := hc.previewPostImages(postItem, hc.preferences.ImageViewer)
 				if err != nil {
 					fmt.Printf("Image preview failed: %v\n", err)
--