Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added redis shorthand command #413

Merged
merged 9 commits into from
Aug 28, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions commands/redis.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
[[ ! ${WARDEN_DIR} ]] && >&2 echo -e "\033[31mThis script is not intended to be run directly!\033[0m" && exit 1

WARDEN_ENV_PATH="$(locateEnvPath)" || exit $?
loadEnvConfig "${WARDEN_ENV_PATH}" || exit $?
assertDockerRunning

if [[ ${WARDEN_REIDS:-1} -eq 0 ]]; then
fatal "Redis environment is not used (WARDEN_REDIS=1)."
fi
werfu marked this conversation as resolved.
Show resolved Hide resolved

if [[ "${WARDEN_PARAMS[0]}" == "help" ]]; then
warden redis --help || exit $? && exit $?
fi

## load connection information for the redis service
REDIS_CONTAINER=$(warden env ps -q redis)
if [[ ! ${REDIS_CONTAINER} ]]; then
fatal "No container found for redis service."
fi

if [[ "${WARDEN_PARAMS[0]}" == "stat" ]]; then
"${WARDEN_DIR}/bin/warden" env exec redis sh -c "redis-cli --stat"
fi

if (( ${#WARDEN_PARAMS[@]} == 0 )); then
"${WARDEN_DIR}/bin/warden" env exec redis sh -c "redis-cli"
else
"${WARDEN_DIR}/bin/warden" env exec -T redis sh -c "redis-cli ${WARDEN_PARAMS}"
fi
werfu marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 13 additions & 0 deletions commands/redis.help
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
[[ ! ${WARDEN_DIR} ]] && >&2 echo -e "\033[31mThis script is not intended to be run directly!\033[0m" && exit 1

WARDEN_USAGE=$(cat <<EOF
\033[33mUsage:\033[0m
redis stat Run continuous stat mode
redis COMMAND Execute the Redis command within the current project environment
redis Launches an interactive redis session within the current project environment

\033[33mOptions:\033[0m
-h, --help Display this help menu
EOF
)
1 change: 1 addition & 0 deletions commands/usage.help
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Warden version $(cat ${WARDEN_DIR}/version)
env-init Configure environment by adding '.env' file to the current working directory
env Controls an environment from any point within the root project directory
db Interacts with the db service on an environment (see 'warden db -h' for details)
redis Interacts with the redis service on an environment (see 'warden redis -h' for details)
install Initializes or updates warden configuration on host machine
shell Launches into a shell within the current project environment
debug Launches debug enabled shell within current project environment
Expand Down
7 changes: 5 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ Flush varnish:

Connect to redis:

warden env exec redis redis-cli
warden redis

Flush redis completely:

warden env exec -T redis redis-cli flushall
warden redis flushall

Run redis continous stat mode
warden redis stat
werfu marked this conversation as resolved.
Show resolved Hide resolved

Remove volumes completely:

Expand Down