mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-09-03 23:57:27 -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
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
//go:build !windows
|
|
||||||
|
|
||||||
package backend
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
func textEditorFallback() string {
|
|
||||||
// ensure textEditor is set
|
|
||||||
textEditor := os.Getenv("EDITOR")
|
|
||||||
if textEditor == "" {
|
|
||||||
textEditor = FallbackEditor
|
|
||||||
}
|
|
||||||
return textEditor
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
//go:build windows
|
|
||||||
|
|
||||||
package backend
|
|
||||||
|
|
||||||
const FallbackEditor = "nvim" // since there is no pre-installed CLI editor on Windows, default to the most popular one
|
|
||||||
|
|
||||||
// textEditorFallback returns FallbackEditor
|
|
||||||
func textEditorFallback() string {
|
|
||||||
return FallbackEditor
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user