mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-24 13:47:35 +00:00
Rename $_DEFINED_COMMANDS
to $_DEFINED_SUBCOMMANDS
.
This commit is contained in:
parent
379f99f4e1
commit
768acb5d80
18
hosts
18
hosts
@ -758,10 +758,10 @@ HEREDOC
|
|||||||
commands() {
|
commands() {
|
||||||
if [[ "${1:-}" == "--raw" ]]
|
if [[ "${1:-}" == "--raw" ]]
|
||||||
then
|
then
|
||||||
printf "%s\\n" "${_DEFINED_COMMANDS[@]}"
|
printf "%s\\n" "${_DEFINED_SUBCOMMANDS[@]}"
|
||||||
else
|
else
|
||||||
printf "Available commands:\\n"
|
printf "Available commands:\\n"
|
||||||
printf " %s\\n" "${_DEFINED_COMMANDS[@]}"
|
printf " %s\\n" "${_DEFINED_SUBCOMMANDS[@]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1584,8 +1584,8 @@ _debug printf \
|
|||||||
|
|
||||||
# Load Commands ###############################################################
|
# Load Commands ###############################################################
|
||||||
|
|
||||||
# Initialize $_DEFINED_COMMANDS array.
|
# Initialize $_DEFINED_SUBCOMMANDS array.
|
||||||
_DEFINED_COMMANDS=()
|
_DEFINED_SUBCOMMANDS=()
|
||||||
|
|
||||||
# _load_subcommands()
|
# _load_subcommands()
|
||||||
#
|
#
|
||||||
@ -1619,7 +1619,7 @@ _load_subcommands() {
|
|||||||
"_load_subcommands() \${_function_name}: %s\\n" \
|
"_load_subcommands() \${_function_name}: %s\\n" \
|
||||||
"${_function_name}"
|
"${_function_name}"
|
||||||
|
|
||||||
# Add the function name to the $_DEFINED_COMMANDS array unless it starts
|
# Add the function name to the $_DEFINED_SUBCOMMANDS array unless it starts
|
||||||
# with an underscore or is one of the desc(), or debug() functions,
|
# with an underscore or is one of the desc(), or debug() functions,
|
||||||
# since these are treated as having 'private' visibility.
|
# since these are treated as having 'private' visibility.
|
||||||
if ! { [[ "${_function_name}" =~ ^_(.*) ]] || \
|
if ! { [[ "${_function_name}" =~ ^_(.*) ]] || \
|
||||||
@ -1627,13 +1627,13 @@ _load_subcommands() {
|
|||||||
[[ "${_function_name}" == "debug" ]]
|
[[ "${_function_name}" == "debug" ]]
|
||||||
}
|
}
|
||||||
then
|
then
|
||||||
_DEFINED_COMMANDS+=("${_function_name}")
|
_DEFINED_SUBCOMMANDS+=("${_function_name}")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
_debug printf \
|
_debug printf \
|
||||||
"commands() \${_DEFINED_COMMANDS[*]:-}:\\n%s\\n" \
|
"commands() \${_DEFINED_SUBCOMMANDS[*]:-}:\\n%s\\n" \
|
||||||
"${_DEFINED_COMMANDS[*]:-}"
|
"${_DEFINED_SUBCOMMANDS[*]:-}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main ########################################################################
|
# Main ########################################################################
|
||||||
@ -1657,7 +1657,7 @@ _main() {
|
|||||||
|
|
||||||
_load_subcommands
|
_load_subcommands
|
||||||
|
|
||||||
if _contains "${_SUBCOMMAND}" "${_DEFINED_COMMANDS[@]:-}"
|
if _contains "${_SUBCOMMAND}" "${_DEFINED_SUBCOMMANDS[@]:-}"
|
||||||
then
|
then
|
||||||
"${_SUBCOMMAND}" "${_COMMAND_PARAMETERS[@]:-}"
|
"${_SUBCOMMAND}" "${_COMMAND_PARAMETERS[@]:-}"
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user