mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 08:37:20 -04:00
Move text editor determination to cli package
This commit is contained in:
+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)?")
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
//go:build !windows
|
||||||
|
|
||||||
|
package cli
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package cli
|
||||||
|
|
||||||
|
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