mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-02 15:17:24 -04:00
Simplify text editor fallback
This commit is contained in:
+2
-4
@@ -1,6 +1,7 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -27,10 +28,7 @@ func TempInitCli() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// textEditor
|
// textEditor
|
||||||
textEditor := input("Text editor (leave blank for $EDITOR, falls back to \"" + fallbackEditor + "\"):")
|
textEditor := cmp.Or(input("Text editor (leave blank for $EDITOR, falls back to \""+fallbackEditor+"\"):"), os.Getenv("EDITOR"), fallbackEditor)
|
||||||
if textEditor == "" {
|
|
||||||
textEditor = textEditorFallback()
|
|
||||||
}
|
|
||||||
|
|
||||||
// SSH info
|
// SSH info
|
||||||
configSSH := inputBinary("Configure SSH settings (for synchronization)?")
|
configSSH := inputBinary("Configure SSH settings (for synchronization)?")
|
||||||
|
|||||||
+1
-14
@@ -2,17 +2,4 @@
|
|||||||
|
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
const fallbackEditor = "vi" // vi is pre-installed on most UNIX-like systems
|
||||||
"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 {
|
|
||||||
textEditor := os.Getenv("EDITOR")
|
|
||||||
if textEditor == "" {
|
|
||||||
textEditor = fallbackEditor
|
|
||||||
}
|
|
||||||
return textEditor
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,8 +3,3 @@
|
|||||||
package cli
|
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
|
|
||||||
func textEditorFallback() string {
|
|
||||||
return fallbackEditor
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user