github.com/cli/cli@v1.14.1-0.20210902173923-1af6a669e342/pkg/cmdutil/legacy.go (about) 1 package cmdutil 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/cli/cli/internal/config" 8 ) 9 10 // TODO: consider passing via Factory 11 // TODO: support per-hostname settings 12 func DetermineEditor(cf func() (config.Config, error)) (string, error) { 13 editorCommand := os.Getenv("GH_EDITOR") 14 if editorCommand == "" { 15 cfg, err := cf() 16 if err != nil { 17 return "", fmt.Errorf("could not read config: %w", err) 18 } 19 editorCommand, _ = cfg.Get("", "editor") 20 } 21 22 return editorCommand, nil 23 }