[READ-ONLY] Mirror of https://github.com/probablykasper/my-bash-scripts. My personal bash scripts
cli
0

Configure Feed

Select the types of activity you want to include in your feed.

d-c: No longer runs "docker-compose down" if --detach is present

Kasper (Oct 8, 2019, 11:27 PM +0200) 2d5ee65b 86ddd897

+15 -4
+2 -2
README.md
··· 24 24 25 25 ## d-c 26 26 Basic wrapper around the `docker-compose` command (which you should have if you got Docker installed). The command works the same as `docker-compose`, except: 27 - - When running `d-c run`, it automatically adds the `--rm` argument 28 - - When running `d-c up`, it automatically runs `docker-compose down` afterwards. 27 + - When running `d-c run`, the `--rm` argument is added (as long as `-d` or `--detach` are not present). 28 + - When running `d-c up`, `d-c down` runs afterwards (as long as `-d` or `--detach` are not present). 29 29 30 30 If you've installed auto completion for `docker-compose` ([here's how to do that](https://docs.docker.com/compose/completion/)), you can enable auto completion for `d-c` by adding `complete -F _docker_compose d-c` to your `.bash-profile`. 31 31
+13 -2
bin/d-c
··· 1 1 #! /bin/bash 2 2 3 - if [[ $1 == "run" ]]; then 3 + # check for -d, --detached 4 + DETACHED=false 5 + for (( i=1; i <= "$#"; i++ )); do 6 + ARG="${!i}" 7 + case "$ARG" in 8 + -d|--detach) 9 + DETACHED=true 10 + ;; 11 + esac 12 + done 13 + 14 + if [[ $1 == "run" ]] && [[ $DETACHED == false ]]; then 4 15 docker-compose run --rm "${@:2}" 5 - elif [[ $1 == "up" ]]; then 16 + elif [[ $1 == "up" ]] && [[ $DETACHED == false ]]; then 6 17 docker-compose up "${@:2}"; docker-compose down 7 18 else 8 19 docker-compose "${@:1}"