main/source_dir
This commit is contained in:
parent
ff077a039a
commit
4c862481f7
1 changed files with 30 additions and 32 deletions
62
sh/main.sh
62
sh/main.sh
|
@ -38,34 +38,6 @@ _sh_main_log() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# sort
|
|
||||||
|
|
||||||
main_source_directory() {
|
|
||||||
local path="${1}"
|
|
||||||
[ -d "${path}" ] ||
|
|
||||||
return 1
|
|
||||||
local cmd count module modules
|
|
||||||
modules="$(sh_find_sh "${path}" "${SH_MAIN_NAME}")"
|
|
||||||
_sh_ifs_new
|
|
||||||
count=0
|
|
||||||
_sh_main_log "" \
|
|
||||||
". ${path}"
|
|
||||||
for module in ${modules}; do
|
|
||||||
count=$((count + 1))
|
|
||||||
_sh_main_log "$(printf "%02d" "${count}") ${module%.sh}"
|
|
||||||
module="${path}/${module}"
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
. "${module}"
|
|
||||||
cmd="$(sh_grep_functions "${module}")"
|
|
||||||
if [ -n "${cmd}" ]; then
|
|
||||||
[ -n "${CMD}" ] && CMD="${CMD}
|
|
||||||
"
|
|
||||||
CMD="${CMD}${cmd}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
_sh_ifs_pop
|
|
||||||
}
|
|
||||||
|
|
||||||
# public
|
# public
|
||||||
|
|
||||||
sh_find_extension() {
|
sh_find_extension() {
|
||||||
|
@ -102,18 +74,44 @@ sh_help() {
|
||||||
"u__… = user"
|
"u__… = user"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sh_source_directory() {
|
||||||
|
local path="${1}"
|
||||||
|
[ -d "${path}" ] ||
|
||||||
|
return 1
|
||||||
|
local cmd count module modules
|
||||||
|
modules="$(sh_find_sh "${path}" "${SH_MAIN_NAME}")"
|
||||||
|
_sh_ifs_new
|
||||||
|
count=0
|
||||||
|
_sh_main_log "" \
|
||||||
|
". ${path}"
|
||||||
|
for module in ${modules}; do
|
||||||
|
count=$((count + 1))
|
||||||
|
_sh_main_log "$(printf "%02d" "${count}") ${module%.sh}"
|
||||||
|
module="${path}/${module}"
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
. "${module}"
|
||||||
|
cmd="$(sh_grep_functions "${module}")"
|
||||||
|
if [ -n "${cmd}" ]; then
|
||||||
|
[ -n "${CMD}" ] && CMD="${CMD}
|
||||||
|
"
|
||||||
|
CMD="${CMD}${cmd}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
_sh_ifs_pop
|
||||||
|
}
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
sh_main() {
|
sh_main() {
|
||||||
if ! main_source_directory "${SH_ROOT}"; then
|
if ! sh_source_directory "${SH_ROOT}"; then
|
||||||
_sh_main_log "Not a directory: ${SH_ROOT}"
|
_sh_main_log "Not a directory: ${SH_ROOT}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
main_source_directory "${SH_USER}"
|
sh_source_directory "${SH_USER}"
|
||||||
sh_log
|
sh_log
|
||||||
sh_shellcheck "${SH_ROOT}"
|
sh_shellcheck "${SH_ROOT}"
|
||||||
sh_log
|
sh_log
|
||||||
sh_help
|
sh_help
|
||||||
}
|
}
|
||||||
|
|
||||||
# main
|
|
||||||
|
|
||||||
sh_main
|
sh_main
|
||||||
|
|
Loading…
Reference in a new issue