mirror of
https://github.com/infra7ti/dbtool.git
synced 2025-12-05 23:02:37 -03:00
Initial commit
This commit is contained in:
19
lib/builtin/getopts.bash
Normal file
19
lib/builtin/getopts.bash
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
declare -g options=':'
|
||||
declare -Ag arguments=()
|
||||
|
||||
function _requires_opt() {
|
||||
set +u
|
||||
local _opt=${1:-}
|
||||
local _var=$(eval echo ${2:-})
|
||||
|
||||
if [[ -z "${_var}" ]] && [[ ! -z "${_opt}" ]]; then
|
||||
${ui}.error && \
|
||||
${ui}.print \
|
||||
$"Required option missing: '-%s'. You must provide it.\n\n" \
|
||||
${_opt}
|
||||
exit -1
|
||||
fi
|
||||
set -u
|
||||
}
|
||||
Reference in New Issue
Block a user