@@ -111,6 +111,27 @@ _editor_define_standard() {
111111 }
112112}
113113
114+ # Terminal editor adapter builder — for editors that run in the current terminal
115+ # Sets globals then call this: _EDITOR_CMD, _EDITOR_ERR_MSG, _EDITOR_BACKGROUND (optional, 0 or 1)
116+ _editor_define_terminal () {
117+ editor_can_open () {
118+ command -v " $_EDITOR_CMD " > /dev/null 2>&1
119+ }
120+
121+ editor_open () {
122+ local path=" $1 "
123+ if ! editor_can_open; then
124+ log_error " $_EDITOR_ERR_MSG "
125+ return 1
126+ fi
127+ if [ " ${_EDITOR_BACKGROUND:- 0} " = " 1" ]; then
128+ " $_EDITOR_CMD " " $path " &
129+ else
130+ (cd " $path " && " $_EDITOR_CMD " .)
131+ fi
132+ }
133+ }
134+
114135# Main dispatcher
115136main () {
116137 local cmd=" ${1:- help} "
@@ -276,7 +297,7 @@ _auto_launch_editor() {
276297 local editor
277298 editor=$( cfg_default gtr.editor.default GTR_EDITOR_DEFAULT " none" defaults.editor)
278299 if [ " $editor " != " none" ]; then
279- load_editor_adapter " $editor "
300+ load_editor_adapter " $editor " || return 1
280301 local workspace_file
281302 workspace_file=$( resolve_workspace_file " $worktree_path " )
282303 log_step " Opening in $editor ..."
@@ -295,7 +316,7 @@ _auto_launch_ai() {
295316 if [ " $ai_tool " = " none" ]; then
296317 log_warn " No AI tool configured. Set with: git gtr config set gtr.ai.default claude"
297318 else
298- load_ai_adapter " $ai_tool "
319+ load_ai_adapter " $ai_tool " || return 1
299320 log_step " Starting $ai_tool ..."
300321 ai_start " $worktree_path "
301322 fi
@@ -455,8 +476,8 @@ cmd_create() {
455476 log_info " Worktree created: $worktree_path "
456477
457478 # Auto-launch editor/AI or show next steps
458- [ " $open_editor " -eq 1 ] && _auto_launch_editor " $worktree_path "
459- [ " $start_ai " -eq 1 ] && _auto_launch_ai " $worktree_path "
479+ [ " $open_editor " -eq 1 ] && { _auto_launch_editor " $worktree_path " || true ; }
480+ [ " $start_ai " -eq 1 ] && { _auto_launch_ai " $worktree_path " || true ; }
460481 if [ " $open_editor " -eq 0 ] && [ " $start_ai " -eq 0 ]; then
461482 _post_create_next_steps " $branch_name " " $folder_name " " $folder_override " " $repo_root " " $base_dir " " $prefix "
462483 fi
@@ -926,7 +947,7 @@ cmd_editor() {
926947 log_info " Opened in file browser"
927948 else
928949 # Load editor adapter and open
929- load_editor_adapter " $editor "
950+ load_editor_adapter " $editor " || exit 1
930951 local workspace_file
931952 workspace_file=$( resolve_workspace_file " $worktree_path " )
932953 log_step " Opening in $editor ..."
@@ -983,7 +1004,7 @@ cmd_ai() {
9831004 fi
9841005
9851006 # Load AI adapter
986- load_ai_adapter " $ai_tool "
1007+ load_ai_adapter " $ai_tool " || exit 1
9871008
9881009 resolve_repo_context || exit 1
9891010 local repo_root=" $_ctx_repo_root " base_dir=" $_ctx_base_dir " prefix=" $_ctx_prefix "
@@ -1525,6 +1546,9 @@ cmd_config() {
15251546 if [ -n " $extra_args " ]; then
15261547 log_warn " set action: ignoring extra arguments: $extra_args "
15271548 fi
1549+ if ! _cfg_is_known_key " $key " ; then
1550+ log_warn " Unknown config key: $key (not a recognized gtr.* key)"
1551+ fi
15281552 cfg_set " $key " " $value " " $resolved_scope "
15291553 log_info " Config set: $key = $value ($resolved_scope )"
15301554 ;;
@@ -1537,6 +1561,9 @@ cmd_config() {
15371561 if [ -n " $extra_args " ]; then
15381562 log_warn " add action: ignoring extra arguments: $extra_args "
15391563 fi
1564+ if ! _cfg_is_known_key " $key " ; then
1565+ log_warn " Unknown config key: $key (not a recognized gtr.* key)"
1566+ fi
15401567 cfg_add " $key " " $value " " $resolved_scope "
15411568 log_info " Config added: $key = $value ($resolved_scope )"
15421569 ;;
@@ -1549,6 +1576,9 @@ cmd_config() {
15491576 if [ -n " $value " ] || [ -n " $extra_args " ]; then
15501577 log_warn " unset action: ignoring extra arguments: ${value}${value: + }${extra_args} "
15511578 fi
1579+ if ! _cfg_is_known_key " $key " ; then
1580+ log_warn " Unknown config key: $key (not a recognized gtr.* key)"
1581+ fi
15521582 cfg_unset " $key " " $resolved_scope "
15531583 log_info " Config unset: $key ($resolved_scope )"
15541584 ;;
@@ -1878,7 +1908,7 @@ _load_adapter() {
18781908 log_error " $label '$name ' not found"
18791909 log_info " Built-in adapters: $builtin_list "
18801910 log_info " Or use any $label command available in your PATH (e.g., $path_hint )"
1881- exit 1
1911+ return 1
18821912 fi
18831913
18841914 # Set globals for generic adapter functions
0 commit comments