Allow passing arguments to logs

This commit is contained in:
3wc 2020-09-12 14:00:28 +02:00
parent b67d45e14d
commit 76986927eb

21
abra
View File

@ -24,10 +24,11 @@ sub_help() {
echo "Usage: $PROGRAM_NAME [-a STACK_NAME] <subcommand> [options]"
echo ""
echo "Subcommands:"
echo " run SERVICE [CMD] run a command in the specified service's container"
echo " run SERVICE CMD run a command in the specified service's container"
echo " run_args SERVICE ARGS CMD run, passing extra args to docker exec"
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 " logs SERVICE [ARGS] tail logs from a deployed service"
echo " ... (custom commands)"
echo ""
echo "Make sure \$STACK_NAME is set using direnv or -a"
@ -50,7 +51,7 @@ sub_secret_generate(){
sub_run_args(){
SERVICE=$1
ARGS=$2
DOCKER_ARGS=$2
shift 2
@ -67,7 +68,7 @@ sub_run_args(){
exit
fi
docker exec $ARGS -it "$CONTAINER" $@
docker exec $DOCKER_ARGS -it "$CONTAINER" $@
return
}
@ -106,11 +107,19 @@ sub_deploy (){
sub_logs (){
SERVICE=$1
docker service logs "${STACK_NAME}_${SERVICE}" \
shift
if [ $# -eq 0 ]; then
LOGS_ARGS="\
--follow \
--no-trunc \
--details \
--timestamps
--timestamps"
else
LOGS_ARGS="$@"
fi
docker service logs "${STACK_NAME}_${SERVICE}" $LOGS_ARGS
}
subcommand=$1