mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 08:37:20 -04:00
Re-use text editor input code
This commit is contained in:
@@ -195,7 +195,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
case "init":
|
case "init":
|
||||||
err := core.LibmuttonInit(front.Input,
|
err := core.LibmuttonInit(front.Input,
|
||||||
[][3]string{{"MUTN", "textEditor", cmp.Or(front.Input("Text editor (leave blank for $EDITOR, falls back to \""+cli.FallbackEditor+"\"):"), os.Getenv("EDITOR"), cli.FallbackEditor)}},
|
[][3]string{{"MUTN", "textEditor", getTextEditorInput()}},
|
||||||
confirmRCWPassphrase("new"), false)
|
confirmRCWPassphrase("new"), false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
other.PrintError("Initialization failed: "+err.Error(), 0)
|
other.PrintError("Initialization failed: "+err.Error(), 0)
|
||||||
@@ -223,7 +223,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
fmt.Println("\nRe-encryption complete.")
|
fmt.Println("\nRe-encryption complete.")
|
||||||
case 3:
|
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)
|
err := cfg.WriteConfig([][3]string{{"MUTN", "textEditor", getTextEditorInput()}}, nil, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
other.PrintError("Failed to set text editor: "+err.Error(), back.ErrorWrite)
|
other.PrintError("Failed to set text editor: "+err.Error(), back.ErrorWrite)
|
||||||
}
|
}
|
||||||
@@ -258,3 +258,8 @@ func confirmRCWPassphrase(lowercasePrefix string) []byte {
|
|||||||
return rcwPass
|
return rcwPass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getTextEditorInput prompts the user for a text editor input, first falling back to "$EDITOR", then to a default value
|
||||||
|
func getTextEditorInput() string {
|
||||||
|
return cmp.Or(front.Input("Text editor (leave blank for $EDITOR, falls back to \""+cli.FallbackEditor+"\"):"), os.Getenv("EDITOR"), cli.FallbackEditor)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user