subcommand restructure and bashstyle refactor. closes #1579
This commit is contained in:
committed by
Michael Hobbs
parent
76e27f0333
commit
89f289b433
@@ -1,43 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
[[ " events events:on events:off events:list help events:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
[[ " help events:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
case "$1" in
|
||||
events)
|
||||
if [[ -f $DOKKU_EVENTS_LOGFILE ]]; then
|
||||
if [[ $2 == "-t" ]]; then
|
||||
tail -F "$DOKKU_EVENTS_LOGFILE"
|
||||
else
|
||||
tail -n 100 "$DOKKU_EVENTS_LOGFILE"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
events:on)
|
||||
echo "Enabling dokku events logger"
|
||||
[[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc"
|
||||
echo "export DOKKU_EVENTS=1" > "$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS"
|
||||
;;
|
||||
|
||||
events:off)
|
||||
echo "Disabling dokku events logger"
|
||||
rm -f "$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS"
|
||||
;;
|
||||
|
||||
events:list)
|
||||
PLUGIN_DIR="$(dirname "$0")/"
|
||||
if [[ "$DOKKU_EVENTS" ]]; then
|
||||
logged="$(find "$PLUGIN_DIR" -type l -printf '%f ' | sort)"
|
||||
dokku_col_log_info2_quiet "Events currently logged"
|
||||
for hook in $logged; do
|
||||
dokku_col_log_msg "$hook"
|
||||
done
|
||||
else
|
||||
dokku_log_warn "Events logger disabled"
|
||||
fi
|
||||
;;
|
||||
|
||||
help | events:help)
|
||||
cat<<EOF
|
||||
events [-t], Show the last events (-t follows)
|
||||
|
||||
17
plugins/20_events/subcommands/default
Executable file
17
plugins/20_events/subcommands/default
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
events_main_cmd() {
|
||||
local desc="shows contents of dokku events log"
|
||||
local cmd="events"
|
||||
if [[ -f $DOKKU_EVENTS_LOGFILE ]]; then
|
||||
if [[ $2 == "-t" ]]; then
|
||||
tail -F "$DOKKU_EVENTS_LOGFILE"
|
||||
else
|
||||
tail -n 100 "$DOKKU_EVENTS_LOGFILE"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
events_main_cmd "$@"
|
||||
23
plugins/20_events/subcommands/list
Executable file
23
plugins/20_events/subcommands/list
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
events_list_cmd() {
|
||||
local desc="lists enabled events"
|
||||
local cmd="events:list"
|
||||
local PLUGIN_DIR="$(dirname "$0")/.."
|
||||
|
||||
if [[ "$DOKKU_EVENTS" ]]; then
|
||||
local logged="$(find "$PLUGIN_DIR" -type l -printf '%f ' | sort)"
|
||||
dokku_col_log_info2_quiet "Events currently logged"
|
||||
|
||||
local hook
|
||||
for hook in $logged; do
|
||||
dokku_col_log_msg "$hook"
|
||||
done
|
||||
else
|
||||
dokku_log_warn "Events logger disabled"
|
||||
fi
|
||||
}
|
||||
|
||||
events_list_cmd "$@"
|
||||
12
plugins/20_events/subcommands/off
Executable file
12
plugins/20_events/subcommands/off
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
events_off_cmd() {
|
||||
local desc="disables dokku events logger"
|
||||
local cmd="events:off"
|
||||
echo "Disabling dokku events logger"
|
||||
rm -f "$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS"
|
||||
}
|
||||
|
||||
events_off_cmd "$@"
|
||||
13
plugins/20_events/subcommands/on
Executable file
13
plugins/20_events/subcommands/on
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
events_on_cmd() {
|
||||
local desc="enables dokku events logger"
|
||||
local cmd="events:on"
|
||||
echo "Enabling dokku events logger"
|
||||
[[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc"
|
||||
echo "export DOKKU_EVENTS=1" > "$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS"
|
||||
}
|
||||
|
||||
events_on_cmd "$@"
|
||||
Reference in New Issue
Block a user