Skip to content
This repository was archived by the owner on May 17, 2023. It is now read-only.

Commit 346e36d

Browse files
committed
Merge branch 'feature/container-shortcuts'
2 parents 7c626ec + d0a2d65 commit 346e36d

12 files changed

Lines changed: 83 additions & 10 deletions

File tree

.editorconfig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
root = true
22

33
[*]
4-
indent_size = 4
54
charset = utf-8
65
end_of_line = lf
7-
indent_style = space
86
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
99
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [0.3.1] - 2020-05-23
7+
## [0.4.0] - 2020-12-06
8+
### Added
9+
- "check" command that shortcuts to check-config.sh devilbox file
10+
- "exec" command that enables command execution without entering the container
11+
- "mysql" command that opens the mysql cli, and possibility to exec query directly
12+
13+
## [0.3.2] - 2020-05-23
814
### Changed
915
- default command shows version and help (@llaville)
1016

bin/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ cat "$SRC_PATH"commands/config/mysql.sh >> "$BUILD" && echo "" >> "$BUILD"
2323
cat "$SRC_PATH"commands/config/docroot.sh >> "$BUILD" && echo "" >> "$BUILD"
2424
cat "$SRC_PATH"commands/config/projects.sh >> "$BUILD" && echo "" >> "$BUILD"
2525

26+
cat "$SRC_PATH"commands/check.sh >> "$BUILD" && echo "" >> "$BUILD"
2627
cat "$SRC_PATH"commands/config.sh >> "$BUILD" && echo "" >> "$BUILD"
2728
cat "$SRC_PATH"commands/enter.sh >> "$BUILD" && echo "" >> "$BUILD"
29+
cat "$SRC_PATH"commands/exec.sh >> "$BUILD" && echo "" >> "$BUILD"
2830
cat "$SRC_PATH"commands/help.sh >> "$BUILD" && echo "" >> "$BUILD"
31+
cat "$SRC_PATH"commands/mysql.sh >> "$BUILD" && echo "" >> "$BUILD"
2932
cat "$SRC_PATH"commands/open.sh >> "$BUILD" && echo "" >> "$BUILD"
3033
cat "$SRC_PATH"commands/restart.sh >> "$BUILD" && echo "" >> "$BUILD"
3134
cat "$SRC_PATH"commands/run.sh >> "$BUILD" && echo "" >> "$BUILD"

dist/devilbox-cli.sh

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
VERSION="0.3.2"
4-
DATE="2020-05-27"
3+
VERSION="0.4.0"
4+
DATE="2020-12-06"
55
NAME="devilbox-cli"
66
DESCRIPTION="A simple and conveniant command line to manage devilbox from anywhere"
77
LINK="https://github.com/louisgab/devilbox-cli"
@@ -381,6 +381,10 @@ set_projects_path () {
381381
set_readable_config "Projects path" "$WWWPATH_CONFIG" "$new"
382382
}
383383

384+
check_command () {
385+
./check-config.sh
386+
}
387+
384388
config_command () {
385389
for arg in "$@"; do
386390
case $arg in
@@ -406,7 +410,16 @@ enter_command () {
406410
error "Devilbox containers are not running"
407411
return "$KO_CODE"
408412
fi
409-
sh shell.sh
413+
./shell.sh
414+
}
415+
416+
exec_command() {
417+
if ! is_running; then
418+
error "Devilbox containers are not running"
419+
return "$KO_CODE"
420+
fi
421+
422+
docker-compose exec -u devilbox php bash -c "$@"
410423
}
411424

412425
add_usage_command () {
@@ -455,6 +468,19 @@ help_command () {
455468
printf "\n"
456469
}
457470

471+
mysql_command() {
472+
if ! is_running; then
473+
error "Devilbox containers are not running"
474+
return "$KO_CODE"
475+
fi
476+
477+
if [ -z "$@" ]; then
478+
exec_command 'mysql -hmysql -uroot'
479+
else
480+
exec_command 'mysql -hmysql -uroot -e "$@"'
481+
fi
482+
}
483+
458484
open_http_intranet () {
459485
xdg-open "http://localhost/" 2> /dev/null >/dev/null
460486
}
@@ -612,9 +638,12 @@ main () {
612638
help_command
613639
else
614640
case $1 in
641+
check) shift; check_command;;
615642
c|config) shift; config_command "$@";;
616643
e|enter) shift; enter_command;;
644+
x|exec) shift; exec_command "$@";;
617645
h|help|-h|--help) shift; help_command;;
646+
mysql) shift; mysql_command "$@";;
618647
o|open) shift; open_command "$@";;
619648
restart) shift; restart_command "$@";;
620649
r|run) shift; run_command "$@";;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "devilbox-cli",
3-
"version": "0.3.2",
3+
"version": "0.4.0",
44
"description": "A simple and conveniant command line to manage devilbox from anywhere",
55
"author": "Louis Gabriel <code@louisgab.me>",
66
"license": "MIT",

src/commands/check.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
check_command () {
2+
./check-config.sh
3+
}

src/commands/enter.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ enter_command () {
33
error "Devilbox containers are not running"
44
return "$KO_CODE"
55
fi
6-
sh shell.sh
6+
./shell.sh
77
}

src/commands/exec.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
exec_command() {
2+
if ! is_running; then
3+
error "Devilbox containers are not running"
4+
return "$KO_CODE"
5+
fi
6+
7+
docker-compose exec -u devilbox php bash -c "$@"
8+
}

src/commands/mysql.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mysql_command() {
2+
if ! is_running; then
3+
error "Devilbox containers are not running"
4+
return "$KO_CODE"
5+
fi
6+
7+
if [ -z "$1" ]; then
8+
exec_command 'mysql -hmysql -uroot'
9+
else
10+
exec_command "mysql -hmysql -uroot -e '$1'"
11+
fi
12+
}

src/config.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
VERSION="0.3.2"
4-
DATE="2020-05-27"
3+
VERSION="0.4.0"
4+
DATE="2020-12-06"
55
NAME="devilbox-cli"
66
DESCRIPTION="A simple and conveniant command line to manage devilbox from anywhere"
77
LINK="https://github.com/louisgab/devilbox-cli"

0 commit comments

Comments
 (0)