-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathteamwork-operations
More file actions
executable file
·161 lines (144 loc) · 6.28 KB
/
teamwork-operations
File metadata and controls
executable file
·161 lines (144 loc) · 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env bash
#ddev-generated
#annertech-ddev
## Description: Teamwork Operations Centre (open-issue, comment, timelog, new card)
## Usage: teamwork-operations
## Example: "ddev teamwork-operations"
## Aliases: tw
# Colours
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo_red() { echo -e "${RED}$1${NC}" >&2; }
echo_green() { echo -e "${GREEN}$1${NC}" >&2; }
echo_yellow() { echo -e "${YELLOW}$1${NC}" >&2; }
# Menu options
OPTIONS=(
"1. Open Issue"
"2. Post Comment"
"3. Log Time"
"4. Update Description"
"5. New Card"
)
# Select action
select_action() {
echo_green "Start typing to select an action"
printf '%s\n' "${OPTIONS[@]}" | fzf --reverse --height=50% --header="Action"
}
# Main function
main() {
# Banner
echo_green "
████████╗███████╗ █████╗ ███╗ ███╗██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗
╚══██╔══╝██╔════╝██╔══██╗████╗ ████║██║ ██║██╔═══██╗██╔══██╗██║ ██╔╝
██║ █████╗ ███████║██╔████╔██║██║ █╗ ██║██║ ██║██████╔╝█████╔╝
██║ ██╔══╝ ██╔══██║██║╚██╔╝██║██║███╗██║██║ ██║██╔══██╗██╔═██╗
██║ ███████╗██║ ██║██║ ╚═╝ ██║╚███╔███╔╝╚██████╔╝██║ ██║██║ ██╗
╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
██████╗ ██████╗ ███████╗██████╗ █████╗ ████████╗██╗ ██████╗ ███╗ ██╗███████╗
██╔═══██╗██╔══██╗██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║██╔════╝
██║ ██║██████╔╝█████╗ ██████╔╝███████║ ██║ ██║██║ ██║██╔██╗ ██║███████╗
██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗██╔══██║ ██║ ██║██║ ██║██║╚██╗██║╚════██║
╚██████╔╝██║ ███████╗██║ ██║██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║███████║
╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝
"
echo " by Annertech and Bill Seremetis"
echo ""
# Check for task ID upfront and offer to create branch if needed
branch_name=$(git rev-parse --abbrev-ref HEAD)
if [[ ! $branch_name =~ T-([0-9]+) ]]; then
echo_yellow "No task ID found in current branch (${branch_name})."
echo ""
# Branch options menu
BRANCH_OPTIONS=(
"1. Create a new branch with a task ID"
"2. Go to previous branch (git checkout -)"
"3. Create a new card"
"0. Exit"
)
echo_green "Select an option"
branch_choice=$(printf '%s\n' "${BRANCH_OPTIONS[@]}" | fzf --reverse --height=50% --header="No task branch found")
if [[ -z "$branch_choice" ]]; then
echo_red "Nothing selected... Exiting"
exit 0
fi
# Extract choice number
choice_num=$(echo "$branch_choice" | sed 's/^\([0-9]*\)\..*/\1/')
echo ""
case "$choice_num" in
1)
ddev branch
echo ""
;;
2)
echo_green "Switching to previous branch..."
git checkout -
echo ""
# Check if the new branch has a task ID
branch_name=$(git rev-parse --abbrev-ref HEAD)
if [[ $branch_name =~ T-([0-9]+) ]]; then
echo_green "Now on branch with task: T-${BASH_REMATCH[1]}"
echo_green "Branch: ${branch_name}"
else
echo_yellow "Previous branch (${branch_name}) also has no task ID."
echo_yellow "You'll need to enter task IDs manually."
fi
echo ""
;;
3)
ddev tw-new
exit 0
;;
0)
echo_red "Exiting."
exit 0
;;
*)
echo_red "Invalid choice. Exiting."
exit 1
;;
esac
fi
# Select action
local action_selection
action_selection=$(select_action)
if [[ -z "$action_selection" ]]; then
echo_red "Nothing selected... Exiting"
exit 0
fi
# Extract action from selection (remove number prefix)
local action_label
action_label=$(echo "$action_selection" | sed 's/^[0-9]*\. //')
# Execute selected action
case "$action_label" in
"Open Issue")
ddev open-issue
;;
"Post Comment")
echo_green "Post Comment to Task"
echo ""
ddev tw-comment
;;
"Log Time")
echo_green "Log Time to Task"
echo ""
ddev tw-timelog
;;
"Update Description")
echo_green "Update Task Description"
echo ""
ddev tw-description
;;
"New Card")
echo_green "Create New Teamwork Card"
echo ""
ddev tw-new
;;
*)
echo_red "Unknown action: $action_label"
exit 1
;;
esac
}
main