parent
6cf7cf843a
commit
983e4af08c
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
coverage/
|
coverage/
|
||||||
|
/.venv
|
||||||
|
71
abra
71
abra
@ -26,8 +26,8 @@ View logs from running applications:
|
|||||||
multilogs tail logs from a whole stack
|
multilogs tail logs from a whole stack
|
||||||
|
|
||||||
Interact with running containers:
|
Interact with running containers:
|
||||||
cp copy files to a container
|
cp <src> <dest> copy files to a container
|
||||||
run run a command in the specified service's container
|
run <service> <cmd> run <cmd> in <service>'s container
|
||||||
|
|
||||||
Manage servers:
|
Manage servers:
|
||||||
server add <host> [user] [port] add docker context
|
server add <host> [user] [port] add docker context
|
||||||
@ -135,8 +135,8 @@ eval "var_$1+=($value)"; else eval "var_$1=$value"; fi; return 0; fi; done
|
|||||||
return 1; }; stdout() { printf -- "cat <<'EOM'\n%s\nEOM\n" "$1"; }; stderr() {
|
return 1; }; stdout() { printf -- "cat <<'EOM'\n%s\nEOM\n" "$1"; }; stderr() {
|
||||||
printf -- "cat <<'EOM' >&2\n%s\nEOM\n" "$1"; }; error() {
|
printf -- "cat <<'EOM' >&2\n%s\nEOM\n" "$1"; }; error() {
|
||||||
[[ -n $1 ]] && stderr "$1"; stderr "$usage"; _return 1; }; _return() {
|
[[ -n $1 ]] && stderr "$1"; stderr "$usage"; _return 1; }; _return() {
|
||||||
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1345}
|
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1352}
|
||||||
usage=${DOC:40:131}; digest=f2937; shorts=(-c -e -h -s -v)
|
usage=${DOC:40:131}; digest=3774c; shorts=(-c -e -h -s -v)
|
||||||
longs=(--config --env --help --stack --version); argcounts=(1 1 0 1 0)
|
longs=(--config --env --help --stack --version); argcounts=(1 1 0 1 0)
|
||||||
node_0(){ value __config 0 true; }; node_1(){ value __env 1 true; }; node_2(){
|
node_0(){ value __config 0 true; }; node_1(){ value __env 1 true; }; node_2(){
|
||||||
switch __help 2; }; node_3(){ value __stack 3 true; }; node_4(){
|
switch __help 2; }; node_3(){ value __stack 3 true; }; node_4(){
|
||||||
@ -193,7 +193,6 @@ parse_subcommand() {
|
|||||||
if [ -n "$PREFIX" ]; then
|
if [ -n "$PREFIX" ]; then
|
||||||
PPREFIX="_$2"
|
PPREFIX="_$2"
|
||||||
SPREFIX="$2 "
|
SPREFIX="$2 "
|
||||||
SSPREFIX=" $2"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $SUBCOMMAND in
|
case $SUBCOMMAND in
|
||||||
@ -204,9 +203,7 @@ parse_subcommand() {
|
|||||||
shift 2
|
shift 2
|
||||||
"sub${PPREFIX}_${SUBCOMMAND}" "$@"
|
"sub${PPREFIX}_${SUBCOMMAND}" "$@"
|
||||||
if [ $? = 127 ]; then
|
if [ $? = 127 ]; then
|
||||||
echo "Error: '$SPREFIX$SUBCOMMAND' is not a known subcommand." >&2
|
error "Error: '$SPREFIX$SUBCOMMAND' is not a known subcommand."
|
||||||
echo " Run '$PROGRAM_NAME$SSPREFIX --help' for a list of known subcommands." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -227,37 +224,6 @@ success() {
|
|||||||
|
|
||||||
###### Top-level arguments
|
###### Top-level arguments
|
||||||
|
|
||||||
ABRA_CONFIG=abra.yml
|
|
||||||
if [ "$1" == "-c" ]; then
|
|
||||||
ABRA_CONFIG=$2
|
|
||||||
shift 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" == "-e" ]; then
|
|
||||||
ABRA_ENV=$2
|
|
||||||
shift 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" == "-a" ]; then
|
|
||||||
STACK_NAME=$2
|
|
||||||
shift 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
###### Load config
|
|
||||||
|
|
||||||
if [ -f "$ABRA_CONFIG" ]; then
|
|
||||||
require_yq
|
|
||||||
|
|
||||||
if yml_pattern_exists stack_name; then
|
|
||||||
STACK_NAME=$(yq read "$ABRA_CONFIG" stack_name)
|
|
||||||
fi
|
|
||||||
# FIXME load other variables somehow
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$ABRA_ENV" ]; then
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
source "$ABRA_ENV" || error "Unable to load env from '$ABRA_ENV'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
###### Default settings
|
###### Default settings
|
||||||
|
|
||||||
@ -598,13 +564,30 @@ sub_volume() {
|
|||||||
|
|
||||||
###### Main
|
###### Main
|
||||||
|
|
||||||
# SUBCOMMAND=$1
|
|
||||||
# shift
|
|
||||||
# shellcheck disable=SC2086,SC2068
|
|
||||||
# parse_subcommand $SUBCOMMAND "" $@
|
|
||||||
|
|
||||||
abra() {
|
abra() {
|
||||||
|
declare abra___stack abra___env abra___config abra__command_ abra__args_
|
||||||
|
|
||||||
|
DOCOPT_PREFIX=abra_
|
||||||
eval "$(docopt "$@")"
|
eval "$(docopt "$@")"
|
||||||
|
|
||||||
|
STACK_NAME=$abra___stack
|
||||||
|
|
||||||
|
if [ -n "$abra___env" ]; then
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source "$abra___env" || error "Unable to load env from '$abra___env'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$abra___config" ]; then
|
||||||
|
require_yq
|
||||||
|
|
||||||
|
if yml_pattern_exists stack_name; then
|
||||||
|
STACK_NAME=$(yq read "$ABRA_CONFIG" stack_name)
|
||||||
|
fi
|
||||||
|
# FIXME load other variables somehow
|
||||||
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
"sub_${abra__command_}" ${abra__args_[*]}
|
||||||
}
|
}
|
||||||
|
|
||||||
abra "$@"
|
abra "$@"
|
||||||
|
Reference in New Issue
Block a user