mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Handle cases where the user initialized libmutton in a different client and has no text editor specified (also allow setting a text editor in the tweak menu)
This commit is contained in:
@@ -5,7 +5,7 @@ go 1.24.4
|
|||||||
require (
|
require (
|
||||||
github.com/charmbracelet/glamour v0.7.0
|
github.com/charmbracelet/glamour v0.7.0
|
||||||
github.com/rwinkhart/go-boilerplate v0.1.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
|
golang.org/x/term v0.32.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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-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 h1:NhHwFM3Pgm6zRUfFKvi0p5ndjfFbVWsRwmmhyFlG4PE=
|
||||||
github.com/rwinkhart/go-winio-easy-pipe-handles v0.0.0-20250407031321-96994a0e8410/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
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.20250701025912-1a66a30bc184 h1:qsWfJZ7y4H7MV63rWzDev6G86m24vSV2JLxSlXb/6NU=
|
||||||
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/go.mod h1:bQstQ3YmW21sHUrMJGtO9VcnQbepMcofpWGXVp4Pxsg=
|
||||||
github.com/rwinkhart/peercred-mini v0.1.0 h1:TiS6u8cEWzW55S9X4iVpU72Iuy/NG6rMUJMtUEVEFLw=
|
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/peercred-mini v0.1.0/go.mod h1:+x4Mxc2veE+YePSOpcUasjimh7n799c1KraLuQwHR20=
|
||||||
github.com/rwinkhart/rcw v0.2.1 h1:TCKmk557e/+EH3q1VGWiAnWuP7VUHbyhjtJWwpojPtk=
|
github.com/rwinkhart/rcw v0.2.1 h1:TCKmk557e/+EH3q1VGWiAnWuP7VUHbyhjtJWwpojPtk=
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/rwinkhart/go-boilerplate/back"
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"github.com/rwinkhart/go-boilerplate/front"
|
"github.com/rwinkhart/go-boilerplate/front"
|
||||||
"github.com/rwinkhart/go-boilerplate/other"
|
"github.com/rwinkhart/go-boilerplate/other"
|
||||||
|
"github.com/rwinkhart/libmutton/cfg"
|
||||||
"github.com/rwinkhart/libmutton/core"
|
"github.com/rwinkhart/libmutton/core"
|
||||||
"github.com/rwinkhart/libmutton/crypt"
|
"github.com/rwinkhart/libmutton/crypt"
|
||||||
"github.com/rwinkhart/libmutton/global"
|
"github.com/rwinkhart/libmutton/global"
|
||||||
@@ -200,7 +201,7 @@ func main() {
|
|||||||
other.PrintError("Initialization failed: "+err.Error(), 0)
|
other.PrintError("Initialization failed: "+err.Error(), 0)
|
||||||
}
|
}
|
||||||
case "tweak":
|
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 {
|
switch choice {
|
||||||
case 1:
|
case 1:
|
||||||
oldDeviceID, err := global.GetCurrentDeviceID()
|
oldDeviceID, err := global.GetCurrentDeviceID()
|
||||||
@@ -221,6 +222,11 @@ func main() {
|
|||||||
other.PrintError("Re-encryption failed: "+err.Error(), global.ErrorEncryption)
|
other.PrintError("Re-encryption failed: "+err.Error(), global.ErrorEncryption)
|
||||||
}
|
}
|
||||||
fmt.Println("\nRe-encryption complete.")
|
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":
|
case "copy":
|
||||||
cli.HelpCopy()
|
cli.HelpCopy()
|
||||||
|
|||||||
+4
-1
@@ -88,7 +88,10 @@ func editNote(baseNote []string) ([]string, bool) {
|
|||||||
}(tempFile.Name())
|
}(tempFile.Name())
|
||||||
|
|
||||||
// fetch the user's text editor
|
// 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]
|
editor := editorCfg[0]
|
||||||
|
|
||||||
// write baseNote to tempFile (if it is not empty)
|
// write baseNote to tempFile (if it is not empty)
|
||||||
|
|||||||
Reference in New Issue
Block a user