mirror of
https://github.com/hassio-addons/bashio.git
synced 2025-05-06 12:01:25 +00:00
✨ Adds functions to check if config/var is equal to a value
This commit is contained in:
parent
46aa0b1784
commit
7c7386b502
2 changed files with 28 additions and 3 deletions
|
@ -120,6 +120,29 @@ function bashio::config.is_empty() {
|
||||||
return "${__BASHIO_EXIT_NOK}"
|
return "${__BASHIO_EXIT_NOK}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Checks if a configuration option equals a value.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# $1 Key of the config option
|
||||||
|
# $2 Checks if the configuration option matches
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
function bashio::config.equals() {
|
||||||
|
local key=${1}
|
||||||
|
local equals=${2}
|
||||||
|
local value
|
||||||
|
|
||||||
|
bashio::log.trace "${FUNCNAME[0]}:" "$@"
|
||||||
|
|
||||||
|
value=$(bashio::config "${key}")
|
||||||
|
echo ":P ${value}"
|
||||||
|
if ! bashio::var.equals "${value}" "${equals}"; then
|
||||||
|
return "${__BASHIO_EXIT_NOK}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return "${__BASHIO_EXIT_OK}"
|
||||||
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Checks if a configuration option is true.
|
# Checks if a configuration option is true.
|
||||||
#
|
#
|
||||||
|
@ -386,7 +409,7 @@ function bashio::config.require.password() {
|
||||||
bashio::log.fatal
|
bashio::log.fatal
|
||||||
bashio::log.fatal "Setting a password is required!"
|
bashio::log.fatal "Setting a password is required!"
|
||||||
bashio::log.fatal
|
bashio::log.fatal
|
||||||
bashio::log.fatal "Please password in the '${key}' option."
|
bashio::log.fatal "Please set a password in the '${key}' option."
|
||||||
bashio::log.fatal
|
bashio::log.fatal
|
||||||
bashio::log.fatal "If unsure, check the add-on manual for more information."
|
bashio::log.fatal "If unsure, check the add-on manual for more information."
|
||||||
bashio::log.fatal
|
bashio::log.fatal
|
||||||
|
|
|
@ -98,13 +98,15 @@ function bashio::var.is_empty() {
|
||||||
#
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# $1 Value
|
# $1 Value
|
||||||
|
# $2 Equals value
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
function bashio::var.is_empty() {
|
function bashio::var.equals() {
|
||||||
local value=${1}
|
local value=${1}
|
||||||
|
local equals=${2}
|
||||||
|
|
||||||
bashio::log.trace "${FUNCNAME[0]}:" "$@"
|
bashio::log.trace "${FUNCNAME[0]}:" "$@"
|
||||||
|
|
||||||
if [[ -z "${value}" ]]; then
|
if [[ "${value}" = "${equals}" ]]; then
|
||||||
return "${__BASHIO_EXIT_OK}"
|
return "${__BASHIO_EXIT_OK}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue