diff --git a/abra b/abra index 9c4b0d0..f89c9e2 100755 --- a/abra +++ b/abra @@ -16,7 +16,11 @@ if type direnv > /dev/null 2>&1 && ! direnv status | grep -q 'Found RC allowed t exit fi -sub_help(){ +if [ -f abra-commands.sh ]; then + . abra-commands.sh +fi + +sub_help() { echo "Usage: $PROGRAM_NAME [-a STACK_NAME] [options]" echo "" echo "Subcommands:" @@ -24,8 +28,9 @@ sub_help(){ echo " secret_generate SECRET VERSION [CMD] generate a secret, store it in pass & as a Docker secret" echo " deploy [COMPOSE_FILE] let 'em rip" echo " logs SERVICE tail logs from a deployed service" + echo " ... (custom commands)" echo "" - echo "Make sure \$STACK_NAME is set (probably using direnv)" + echo "Make sure \$STACK_NAME is set using direnv or -a" } sub_secret_generate(){ @@ -43,9 +48,11 @@ sub_secret_generate(){ >(pass insert "hosts/autonomic-swarm/${STACK_NAME}/${SECRET}" -m) } -sub_run(){ +sub_run_args(){ SERVICE=$1 - SH=${2:-/bin/sh} + ARGS=$2 + + shift 2 if [ -z "$SERVICE" ]; then echo "Usage: $PROGRAM_NAME run SERVICE [CMD]" @@ -60,11 +67,19 @@ sub_run(){ exit fi - docker exec -it "$CONTAINER" "$SH" + docker exec $ARGS -it "$CONTAINER" $@ return } +sub_run(){ + SERVICE=$1 + + shift + + sub_run_args "$SERVICE" "" "$@" +} + sub_deploy (){ COMPOSE=${1:-compose.yml}