subcommand restructure and bashstyle refactor. closes #1579
This commit is contained in:
committed by
Michael Hobbs
parent
76e27f0333
commit
89f289b433
@@ -1,53 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
[[ " shell help shell:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
[[ " help shell:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
case "$1" in
|
||||
shell)
|
||||
INPUTRC="$PLUGIN_ROOT/inputrc"
|
||||
HISTFILE=~/.dokku_history
|
||||
|
||||
history -r || true
|
||||
|
||||
trim()
|
||||
{
|
||||
sed -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*$//g'
|
||||
}
|
||||
|
||||
trap 'history -w' EXIT
|
||||
|
||||
while true; do
|
||||
trap '' SIGINT
|
||||
read -rep "dokku> " line || {
|
||||
echo; true; break
|
||||
}
|
||||
trap - SIGINT
|
||||
|
||||
line=$(echo "$line" | trim)
|
||||
CMD=$(echo "$line" | awk '{ print $1 }')
|
||||
|
||||
[[ -z $CMD ]] && continue
|
||||
|
||||
[[ "$line" != "$(fc -ln -1 | trim)" ]] && history -s "$line"
|
||||
|
||||
case $CMD in
|
||||
# shell builtins
|
||||
clear)
|
||||
clear
|
||||
;;
|
||||
|
||||
quit|exit)
|
||||
break
|
||||
;;
|
||||
|
||||
# Not a built-in, run as regular dokku command
|
||||
*)
|
||||
dokku "$line" || true
|
||||
esac
|
||||
|
||||
done
|
||||
;;
|
||||
|
||||
help | shell:help)
|
||||
cat<<EOF
|
||||
shell, Spawn dokku shell
|
||||
|
||||
52
plugins/shell/subcommands/default
Executable file
52
plugins/shell/subcommands/default
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
shell_cmd() {
|
||||
local desc="dokku shell interpreter via command line"
|
||||
local cmd="shell"
|
||||
local INPUTRC="$PLUGIN_ROOT/inputrc"
|
||||
local HISTFILE=~/.dokku_history
|
||||
|
||||
history -r || true
|
||||
|
||||
trim()
|
||||
{
|
||||
sed -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*$//g'
|
||||
}
|
||||
|
||||
trap 'history -w' EXIT
|
||||
|
||||
while true; do
|
||||
trap '' SIGINT
|
||||
read -rep "dokku> " line || {
|
||||
echo; true; break
|
||||
}
|
||||
trap - SIGINT
|
||||
|
||||
local line=$(echo "$line" | trim)
|
||||
local CMD=$(echo "$line" | awk '{ print $1 }')
|
||||
|
||||
[[ -z $CMD ]] && continue
|
||||
|
||||
[[ "$line" != "$(fc -ln -1 | trim)" ]] && history -s "$line"
|
||||
|
||||
case $CMD in
|
||||
# shell builtins
|
||||
clear)
|
||||
clear
|
||||
;;
|
||||
|
||||
quit|exit)
|
||||
break
|
||||
;;
|
||||
|
||||
# Not a built-in, run as regular dokku command
|
||||
*)
|
||||
# shellcheck disable=SC2086
|
||||
dokku $line || true
|
||||
esac
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
shell_cmd
|
||||
Reference in New Issue
Block a user