Load custom commands in a function
This commit is contained in:
parent
b68bfdfb43
commit
b49b510c43
36
abra
36
abra
@ -222,9 +222,6 @@ success() {
|
|||||||
echo "$(tput setaf 2)$*$(tput sgr0)"
|
echo "$(tput setaf 2)$*$(tput sgr0)"
|
||||||
}
|
}
|
||||||
|
|
||||||
###### Top-level arguments
|
|
||||||
|
|
||||||
|
|
||||||
###### Default settings
|
###### Default settings
|
||||||
|
|
||||||
if [ -z "$COMPOSE_FILE" ]; then
|
if [ -z "$COMPOSE_FILE" ]; then
|
||||||
@ -235,15 +232,6 @@ if [ -z "$ABRA_STACK_DIR" ]; then
|
|||||||
ABRA_STACK_DIR="stacks/$SERVICE"
|
ABRA_STACK_DIR="stacks/$SERVICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
load_context() {
|
|
||||||
if [ -z "$DOCKER_CONTEXT" ]; then
|
|
||||||
warning "\$DOCKER_CONTEXT not set, (slowly) looking it up"
|
|
||||||
# shellcheck disable=SC2063
|
|
||||||
DOCKER_CONTEXT=$(docker context ls | grep '*' | cut -d' ' -f1)
|
|
||||||
# FIXME 3wc: make sure grep doesn't parse this, we're want a literal '*'
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
###### Safety checks
|
###### Safety checks
|
||||||
|
|
||||||
require_yq() {
|
require_yq() {
|
||||||
@ -274,17 +262,29 @@ if [ -z "$ABRA_ENV" ] && [ -f .envrc ] && type direnv > /dev/null 2>&1 && ! dire
|
|||||||
error "direnv is blocked, run direnv allow"
|
error "direnv is blocked, run direnv allow"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###### Custom commands
|
###### Run-time loading
|
||||||
|
|
||||||
if [ -f abra-commands.sh ]; then
|
load_custom_commands() {
|
||||||
|
if [ -f abra-commands.sh ]; then
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
source abra-commands.sh
|
source abra-commands.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$ABRA_STACK_DIR/abra-commands.sh" ]; then
|
if [ -f "$ABRA_STACK_DIR/abra-commands.sh" ]; then
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "$ABRA_STACK_DIR/abra-commands.sh"
|
source "$ABRA_STACK_DIR/abra-commands.sh"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
load_context() {
|
||||||
|
# Load current context from env or Docker
|
||||||
|
if [ -z "$DOCKER_CONTEXT" ]; then
|
||||||
|
warning "\$DOCKER_CONTEXT not set, (slowly) looking it up"
|
||||||
|
# shellcheck disable=SC2063
|
||||||
|
DOCKER_CONTEXT=$(docker context ls | grep '*' | cut -d' ' -f1)
|
||||||
|
# make sure grep doesn't parse this, we want a literal '*'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
###### Subcommand `secret`
|
###### Subcommand `secret`
|
||||||
|
|
||||||
@ -586,6 +586,8 @@ abra() {
|
|||||||
# FIXME load other variables somehow
|
# FIXME load other variables somehow
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
load_custom_commands
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
"sub_${abra__command_}" ${abra__args_[*]}
|
"sub_${abra__command_}" ${abra__args_[*]}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user