11#! /bin/bash
22
3- VERSION=" 0.3.2 "
4- DATE=" 2020-05-27 "
3+ VERSION=" 0.4.0 "
4+ DATE=" 2020-12-06 "
55NAME=" devilbox-cli"
66DESCRIPTION=" A simple and conveniant command line to manage devilbox from anywhere"
77LINK=" 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+
384388config_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
412425add_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+
458484open_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 " $@ " ;;
0 commit comments