Skip to content

Commit 42c8746

Browse files
authored
Merge branch 'master' into feature/extend-git-commands
2 parents d8fb997 + 872ce00 commit 42c8746

File tree

6 files changed

+388
-78
lines changed

6 files changed

+388
-78
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ _For managing MySQL/MariaDB databases visually._
4848

4949
* Viewable at: http://localhost:8080
5050
* It supports the following databases...
51-
* mariadb106 (lts)
52-
* mariadb1011 (lts)
51+
* mariadb1011 (lts, deprecated)
52+
* mariadb1104 (lts)
5353

5454
### Mailpit
5555
_For mimicking an email inbox (ala mailtrap) for local usage._

bin/_helpers

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Script Output
5+
#
6+
7+
# Determine width of the program
8+
ACTUAL_WIDTH=$(($(tput cols) - 2))
9+
MAX_WIDTH=100
10+
11+
if test "$ACTUAL_WIDTH" -gt "$MAX_WIDTH"; then
12+
WIDTH=$MAX_WIDTH
13+
else
14+
WIDTH=$ACTUAL_WIDTH
15+
fi
16+
17+
declare BG_R
18+
declare BG_G
19+
declare BG_Y
20+
declare BG_B
21+
declare BG_M
22+
declare BG_C
23+
declare BG_N
24+
25+
declare FG_R
26+
declare FG_G
27+
declare FG_Y
28+
declare FG_B
29+
declare FG_M
30+
declare FG_C
31+
declare FG_N
32+
33+
declare BOLD
34+
declare RESET
35+
36+
# Setup Color Outputs
37+
if test -t 1; then
38+
ncolors=$(tput colors)
39+
40+
if test -n "$ncolors" && test "$ncolors" -ge 8; then
41+
COLOR_R=1 # color code - RED
42+
COLOR_G=2 # color code - GREEN
43+
COLOR_Y=3 # color code - YELLOW
44+
COLOR_B=4 # color code - BLUE
45+
COLOR_M=5 # color code - MAGENTA
46+
COLOR_C=6 # color code - CYAN
47+
COLOR_N=246 # color code - NEUTRAL (GRAY)
48+
49+
BG_R="$(tput setab $COLOR_R)" # Background - RED
50+
BG_G="$(tput setab $COLOR_G)" # Background - GREEN
51+
BG_Y="$(tput setab $COLOR_Y)" # Background - YELLOW
52+
BG_B="$(tput setab $COLOR_B)" # Background - BLUE
53+
BG_M="$(tput setab $COLOR_M)" # Background - MAGENTA
54+
BG_C="$(tput setab $COLOR_C)" # Background - CYAN
55+
BG_N="$(tput setab $COLOR_N)" # Background - NEUTRAL (GRAY)
56+
57+
FG_R="$(tput setaf $COLOR_R)" # Foreground - RED
58+
FG_G="$(tput setaf $COLOR_G)" # Foreground - GREEN
59+
FG_Y="$(tput setaf $COLOR_Y)" # Foreground - YELLOW
60+
FG_B="$(tput setaf $COLOR_B)" # Foreground - BLUE
61+
FG_M="$(tput setaf $COLOR_M)" # Foreground - MAGENTA
62+
FG_C="$(tput setaf $COLOR_C)" # Foreground - CYAN
63+
FG_N="$(tput setaf $COLOR_N)" # Foreground - NEUTRAL (GRAY)
64+
65+
BOLD="$(tput bold)"
66+
RESET="$(tput sgr0)"
67+
fi
68+
fi
69+
70+
function join {
71+
local IFS="$1"
72+
shift
73+
echo "$*"
74+
}
75+
76+
function tag {
77+
local STYLE=$1
78+
local LABEL=$2
79+
shift 2
80+
81+
echo "$@" "${STYLE} ${LABEL} ${RESET} "
82+
}
83+
84+
function output_tagged_string() {
85+
tag "$1" "$2" -n
86+
echo "$3"
87+
}
88+
89+
function output_error {
90+
output_tagged_string "$BG_R" "ERROR" "$1"
91+
}
92+
93+
function output_info {
94+
output_tagged_string "$BG_B" "INFO" "$1"
95+
}
96+
97+
export BG_R
98+
export BG_G
99+
export BG_Y
100+
export BG_B
101+
export BG_M
102+
export BG_C
103+
export BG_N
104+
105+
export FG_R
106+
export FG_G
107+
export FG_Y
108+
export FG_B
109+
export FG_M
110+
export FG_C
111+
export FG_N
112+
113+
export BOLD
114+
export RESET
115+
116+
export WIDTH

bin/hop

Lines changed: 11 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,11 @@
11
#!/usr/bin/env bash
22

3-
HOP_PATH=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4-
TOOLKIT_PATH=$(dirname "$HOP_PATH")
5-
6-
#
7-
# Script Output
8-
#
9-
10-
# Determine width of the program
11-
ACTUAL_WIDTH=$(($(tput cols) - 2))
12-
MAX_WIDTH=100
3+
set -eo pipefail
134

14-
if test "$ACTUAL_WIDTH" -gt "$MAX_WIDTH"; then
15-
WIDTH=$MAX_WIDTH
16-
else
17-
WIDTH=$ACTUAL_WIDTH
18-
fi
19-
20-
# Setup Color Outputs
21-
if test -t 1; then
22-
ncolors=$(tput colors)
23-
24-
if test -n "$ncolors" && test "$ncolors" -ge 8; then
25-
COLOR_R=1 # color code - RED
26-
COLOR_G=2 # color code - GREEN
27-
COLOR_Y=3 # color code - YELLOW
28-
COLOR_B=4 # color code - BLUE
29-
COLOR_M=5 # color code - MAGENTA
30-
COLOR_C=6 # color code - CYAN
31-
COLOR_N=246 # color code - NEUTRAL (GRAY)
32-
33-
BG_R="$(tput setab $COLOR_R)" # Background - RED
34-
BG_G="$(tput setab $COLOR_G)" # Background - GREEN
35-
BG_Y="$(tput setab $COLOR_Y)" # Background - YELLOW
36-
BG_B="$(tput setab $COLOR_B)" # Background - BLUE
37-
#BG_M="$(tput setab $COLOR_M)" # Background - MAGENTA
38-
#BG_C="$(tput setab $COLOR_C)" # Background - CYAN
39-
#BG_N="$(tput setab $COLOR_N)" # Background - NEUTRAL (GRAY)
40-
41-
#FG_R="$(tput setaf $COLOR_R)" # Foreground - RED
42-
#FG_G="$(tput setaf $COLOR_G)" # Foreground - GREEN
43-
#FG_Y="$(tput setaf $COLOR_Y)" # Foreground - YELLOW
44-
#FG_B="$(tput setaf $COLOR_B)" # Foreground - BLUE
45-
FG_M="$(tput setaf $COLOR_M)" # Foreground - MAGENTA
46-
FG_C="$(tput setaf $COLOR_C)" # Foreground - CYAN
47-
FG_N="$(tput setaf $COLOR_N)" # Foreground - NEUTRAL (GRAY)
48-
49-
BOLD="$(tput bold)"
50-
RESET="$(tput sgr0)"
51-
fi
52-
fi
5+
HOP_PATH=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
6+
TOOLKIT_PATH=$(dirname "$HOP_PATH")
537

54-
function join {
55-
local IFS="$1"
56-
shift
57-
echo "$*"
58-
}
8+
source "$TOOLKIT_PATH/bin/_helpers"
599

6010
function describe_command {
6111
local COMMAND_NAME=$1
@@ -79,19 +29,6 @@ function describe_command {
7929
join " " "${SEGMENTS[@]}" "${RESET}"
8030
}
8131

82-
function tag {
83-
local STYLE=$1
84-
local LABEL=$2
85-
shift 2
86-
87-
echo "$@" "${STYLE} ${LABEL} ${RESET} "
88-
}
89-
90-
function output_error {
91-
tag "$BG_R" "ERROR" -n
92-
echo "$1"
93-
}
94-
9532
EXPLAIN_COUNT=0
9633
function explain {
9734
EXPLAIN_COUNT=$((EXPLAIN_COUNT + 1))
@@ -159,6 +96,9 @@ function display_help {
15996
describe_command "seed" "hop artisan db:seed"
16097
describe_command "test" "hop artisan test"
16198
describe_command "tinker" "hop artisan tinker"
99+
echo
100+
tag "$BG_Y$BOLD" "Commands"
101+
describe_command "proxy" "\$@" "Start a proxy for this project."
162102
}
163103

164104
if [ $# -lt 1 ] || [ "$1" == "help" ] || [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$1" == "--help" ]; then
@@ -411,6 +351,10 @@ case $1 in
411351
shift 1
412352
run_exec_command php vendor/bin/pint
413353
;;
354+
"proxy")
355+
shift 1
356+
bash "$TOOLKIT_PATH/bin/proxy" "$@"
357+
;;
414358
"ps"|"status")
415359
shift 1
416360
run_command ps "$@"

0 commit comments

Comments
 (0)