Skip to content

Commit e3c3e36

Browse files
committed
feat: color output, per-command help, and 62 new tests
1 parent 438c9cb commit e3c3e36

File tree

13 files changed

+1046
-14
lines changed

13 files changed

+1046
-14
lines changed

bin/gtr

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
set -e
66

7+
# Debug: show file:line:function on set -e failures
8+
if [ -n "${GTR_DEBUG:-}" ]; then
9+
trap 'printf "ERROR at %s:%s in %s()\n" "${BASH_SOURCE[0]}" "$LINENO" "${FUNCNAME[0]:-main}" >&2' ERR
10+
fi
11+
712
# Version
813
GTR_VERSION="2.2.0"
914

@@ -24,6 +29,7 @@ resolve_script_dir() {
2429
. "$GTR_DIR/lib/ui.sh"
2530
. "$GTR_DIR/lib/args.sh"
2631
. "$GTR_DIR/lib/config.sh"
32+
_ui_apply_color_config
2733
. "$GTR_DIR/lib/platform.sh"
2834
. "$GTR_DIR/lib/core.sh"
2935
. "$GTR_DIR/lib/copy.sh"
@@ -44,6 +50,9 @@ main() {
4450
local cmd="${1:-help}"
4551
shift 2>/dev/null || true
4652

53+
# Set for per-command help (used by show_command_help in ui.sh)
54+
_GTR_CURRENT_COMMAND="$cmd"
55+
4756
case "$cmd" in
4857
new)
4958
cmd_create "$@"
@@ -94,7 +103,7 @@ main() {
94103
echo "git gtr version $GTR_VERSION"
95104
;;
96105
help|--help|-h)
97-
cmd_help
106+
cmd_help "$@"
98107
;;
99108
*)
100109
log_error "Unknown command: $cmd"

completions/_git-gtr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ _git-gtr() {
174174
'--local[Use local git config]' \
175175
'--global[Use global git config]' \
176176
'--system[Use system git config]' \
177-
'*:config key:(gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider)'
177+
'*:config key:(gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider gtr.ui.color)'
178178
;;
179179
set|add|unset)
180180
# Write operations only support --local and --global
181181
# (--system may require root or appropriate file permissions)
182182
_arguments \
183183
'--local[Use local git config]' \
184184
'--global[Use global git config]' \
185-
'*:config key:(gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider)'
185+
'*:config key:(gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider gtr.ui.color)'
186186
;;
187187
esac
188188
fi

completions/git-gtr.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ complete -f -c git -n '__fish_git_gtr_using_command config' -a "
139139
gtr.worktrees.prefix 'Worktree folder prefix'
140140
gtr.defaultBranch 'Default branch'
141141
gtr.provider 'Hosting provider (github, gitlab)'
142+
gtr.ui.color 'Color output mode (auto, always, never)'
142143
"
143144

144145
# Helper function to get branch names and special '1' for main repo

completions/gtr.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ _git_gtr() {
131131
if [[ "$cur" == -* ]]; then
132132
COMPREPLY=($(compgen -W "--local --global --system" -- "$cur"))
133133
else
134-
COMPREPLY=($(compgen -W "gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider" -- "$cur"))
134+
COMPREPLY=($(compgen -W "gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider gtr.ui.color" -- "$cur"))
135135
fi
136136
;;
137137
set|add|unset)
138138
# Write operations only support --local and --global (--system requires root)
139139
if [[ "$cur" == -* ]]; then
140140
COMPREPLY=($(compgen -W "--local --global" -- "$cur"))
141141
else
142-
COMPREPLY=($(compgen -W "gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider" -- "$cur"))
142+
COMPREPLY=($(compgen -W "gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider gtr.ui.color" -- "$cur"))
143143
fi
144144
;;
145145
esac

0 commit comments

Comments
 (0)