Initial commit

This commit is contained in:
Christian Tosta
2024-03-27 10:15:34 -03:00
commit 125ddd20d5
20 changed files with 1959 additions and 0 deletions

19
lib/builtin/getopts.bash Normal file
View 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
}