github.com/ungtb10d/cli/v2@v2.0.0-20221110210412-98537dd9d6a1/pkg/cmdutil/legacy.go (about)

     1  package cmdutil
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/ungtb10d/cli/v2/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  }