Move text editor determination to cli package

This commit is contained in:
2024-07-17 14:59:57 -04:00
parent 2ae4fe19e8
commit 4917149299
4 changed files with 10 additions and 12 deletions
+19
View File
@@ -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
}