diff --git a/go.mod b/go.mod index 5e4d4e4..7d815dd 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.24.4 require ( github.com/charmbracelet/glamour v0.7.0 github.com/rwinkhart/go-boilerplate v0.1.0 - github.com/rwinkhart/libmutton v0.3.2-0.20250619231646-d1b5c50d7066 + github.com/rwinkhart/libmutton v0.3.2-0.20250701025912-1a66a30bc184 golang.org/x/term v0.32.0 ) diff --git a/go.sum b/go.sum index d7e0ce3..af06ec2 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,8 @@ github.com/rwinkhart/go-highlite v0.1.1 h1:9TxbRhYVfD/3YaEgNk1BtEiZ0t8/5mxDUZqNM github.com/rwinkhart/go-highlite v0.1.1/go.mod h1:mWLMtCWcyV0BG4NeyPyAUGMjPvI0ds6vXmUq89QwBFA= github.com/rwinkhart/go-winio-easy-pipe-handles v0.0.0-20250407031321-96994a0e8410 h1:NhHwFM3Pgm6zRUfFKvi0p5ndjfFbVWsRwmmhyFlG4PE= github.com/rwinkhart/go-winio-easy-pipe-handles v0.0.0-20250407031321-96994a0e8410/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/rwinkhart/libmutton v0.3.2-0.20250619231646-d1b5c50d7066 h1:4+AuIidU1Rhxph2+iXOrSlxa41NuALg49xzZYN19p3U= -github.com/rwinkhart/libmutton v0.3.2-0.20250619231646-d1b5c50d7066/go.mod h1:E0+uwcSUDbuwgwEjwmx4unWVyaHNcSS+bbwGiCFAYf0= +github.com/rwinkhart/libmutton v0.3.2-0.20250701025912-1a66a30bc184 h1:qsWfJZ7y4H7MV63rWzDev6G86m24vSV2JLxSlXb/6NU= +github.com/rwinkhart/libmutton v0.3.2-0.20250701025912-1a66a30bc184/go.mod h1:bQstQ3YmW21sHUrMJGtO9VcnQbepMcofpWGXVp4Pxsg= github.com/rwinkhart/peercred-mini v0.1.0 h1:TiS6u8cEWzW55S9X4iVpU72Iuy/NG6rMUJMtUEVEFLw= github.com/rwinkhart/peercred-mini v0.1.0/go.mod h1:+x4Mxc2veE+YePSOpcUasjimh7n799c1KraLuQwHR20= github.com/rwinkhart/rcw v0.2.1 h1:TCKmk557e/+EH3q1VGWiAnWuP7VUHbyhjtJWwpojPtk= diff --git a/mutn.go b/mutn.go index fad2f4d..e90fbfb 100644 --- a/mutn.go +++ b/mutn.go @@ -11,6 +11,7 @@ import ( "github.com/rwinkhart/go-boilerplate/back" "github.com/rwinkhart/go-boilerplate/front" "github.com/rwinkhart/go-boilerplate/other" + "github.com/rwinkhart/libmutton/cfg" "github.com/rwinkhart/libmutton/core" "github.com/rwinkhart/libmutton/crypt" "github.com/rwinkhart/libmutton/global" @@ -200,7 +201,7 @@ func main() { other.PrintError("Initialization failed: "+err.Error(), 0) } case "tweak": - choice := front.InputMenuGen("Action:", []string{"Change device ID", "Change master passphrase/Optimize entries"}) + choice := front.InputMenuGen("Action:", []string{"Change device ID", "Change master passphrase/Optimize entries", "Set text editor"}) switch choice { case 1: oldDeviceID, err := global.GetCurrentDeviceID() @@ -221,6 +222,11 @@ func main() { other.PrintError("Re-encryption failed: "+err.Error(), global.ErrorEncryption) } fmt.Println("\nRe-encryption complete.") + case 3: + err := cfg.WriteConfig([][3]string{{"MUTN", "textEditor", cmp.Or(front.Input("Text editor (leave blank for $EDITOR, falls back to \""+cli.FallbackEditor+"\"):"), os.Getenv("EDITOR"), cli.FallbackEditor)}}, nil, true) + if err != nil { + other.PrintError("Failed to set text editor: "+err.Error(), back.ErrorWrite) + } } case "copy": cli.HelpCopy() diff --git a/src/cli/edit.go b/src/cli/edit.go index cb2f466..4d8b40b 100644 --- a/src/cli/edit.go +++ b/src/cli/edit.go @@ -88,7 +88,10 @@ func editNote(baseNote []string) ([]string, bool) { }(tempFile.Name()) // fetch the user's text editor - editorCfg, _ := cfg.ParseConfig([][2]string{{"MUTN", "textEditor"}}) + editorCfg, err := cfg.ParseConfig([][2]string{{"MUTN", "textEditor"}}) + if err != nil { + other.PrintError("Failed to retrieve text editor from libmutton.ini\n\nPlease specify one with \"mutn tweak\"", back.ErrorRead) + } editor := editorCfg[0] // write baseNote to tempFile (if it is not empty)