mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 16:47:20 -04:00
Move text editor determination to cli package
This commit is contained in:
@@ -66,11 +66,6 @@ func WriteConfig(configFileMap map[string]string, append bool) {
|
|||||||
|
|
||||||
// create LIBMUTTON section
|
// create LIBMUTTON section
|
||||||
libmuttonSection, _ = cfg.NewSection("LIBMUTTON")
|
libmuttonSection, _ = cfg.NewSection("LIBMUTTON")
|
||||||
|
|
||||||
// set default textEditor value
|
|
||||||
if configFileMap["textEditor"] == "" {
|
|
||||||
configFileMap["textEditor"] = textEditorFallback()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// write provided configFileMap key-value pairs to the LIBMUTTON section
|
// write provided configFileMap key-value pairs to the LIBMUTTON section
|
||||||
|
|||||||
+4
-1
@@ -27,7 +27,10 @@ func TempInitCli() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// textEditor
|
// textEditor
|
||||||
textEditor := input("Text editor (leave blank for $EDITOR, falls back to \"" + backend.FallbackEditor + "\"):")
|
textEditor := input("Text editor (leave blank for $EDITOR, falls back to \"" + fallbackEditor + "\"):")
|
||||||
|
if textEditor == "" {
|
||||||
|
textEditor = textEditorFallback()
|
||||||
|
}
|
||||||
|
|
||||||
// SSH info
|
// SSH info
|
||||||
configSSH := inputBinary("Configure SSH settings (for synchronization)?")
|
configSSH := inputBinary("Configure SSH settings (for synchronization)?")
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
//go:build !windows
|
//go:build !windows
|
||||||
|
|
||||||
package backend
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
const FallbackEditor = "vi" // vi is pre-installed on most UNIX systems
|
const fallbackEditor = "vi" // vi is pre-installed on most UNIX systems
|
||||||
|
|
||||||
// textEditorFallback returns the value of the $EDITOR environment variable, or FallbackEditor if it is not set
|
// textEditorFallback returns the value of the $EDITOR environment variable, or FallbackEditor if it is not set
|
||||||
func textEditorFallback() string {
|
func textEditorFallback() string {
|
||||||
// ensure textEditor is set
|
// ensure textEditor is set
|
||||||
textEditor := os.Getenv("EDITOR")
|
textEditor := os.Getenv("EDITOR")
|
||||||
if textEditor == "" {
|
if textEditor == "" {
|
||||||
textEditor = FallbackEditor
|
textEditor = fallbackEditor
|
||||||
}
|
}
|
||||||
return textEditor
|
return textEditor
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
//go:build windows
|
//go:build windows
|
||||||
|
|
||||||
package backend
|
package cli
|
||||||
|
|
||||||
const FallbackEditor = "nvim" // since there is no pre-installed CLI editor on Windows, default to the most popular one
|
const fallbackEditor = "nvim" // since there is no pre-installed CLI editor on Windows, default to the most popular one
|
||||||
|
|
||||||
// textEditorFallback returns FallbackEditor
|
// textEditorFallback returns FallbackEditor
|
||||||
func textEditorFallback() string {
|
func textEditorFallback() string {
|
||||||
return FallbackEditor
|
return fallbackEditor
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user