MCPcopy Create free account
hub / github.com/cli/cli / InitEditorMode

Function InitEditorMode

pkg/cmd/pr/shared/survey.go:426–447  ·  view source on GitHub ↗
(f *cmdutil.Factory, editorMode bool, webMode bool, canPrompt bool)

Source from the content-addressed store, hash-verified

424}
425
426func InitEditorMode(f *cmdutil.Factory, editorMode bool, webMode bool, canPrompt bool) (bool, error) {
427 if err := cmdutil.MutuallyExclusive(
428 "specify only one of `--editor` or `--web`",
429 editorMode,
430 webMode,
431 ); err != nil {
432 return false, err
433 }
434
435 config, err := f.Config()
436 if err != nil {
437 return false, err
438 }
439
440 editorMode = !webMode && (editorMode || config.PreferEditorPrompt("").Value == "enabled")
441
442 if editorMode && !canPrompt {
443 return false, errors.New("--editor or enabled prefer_editor_prompt configuration are not supported in non-tty mode")
444 }
445
446 return editorMode, nil
447}

Callers 1

NewCmdCreateFunction · 0.92

Calls 3

MutuallyExclusiveFunction · 0.92
ConfigMethod · 0.65
PreferEditorPromptMethod · 0.65

Tested by

no test coverage detected