summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <mjo@gentoo.org>2015-12-19 19:06:47 -0500
committerMichael Orlitzky <mjo@gentoo.org>2015-12-19 19:06:47 -0500
commita3091c3b9dcae38cc1b6a78f8f963e2cbc3144be (patch)
tree17c694198e922f8d51f378571ef6fffeb986db3e
parentAdd the find_sapi_targets() function and refactor. (diff)
downloadeselect-php-a3091c3b9dcae38cc1b6a78f8f963e2cbc3144be.tar.gz
eselect-php-a3091c3b9dcae38cc1b6a78f8f963e2cbc3144be.tar.bz2
eselect-php-a3091c3b9dcae38cc1b6a78f8f963e2cbc3144be.zip
Consolidate all list_foo actions into one new list_sapi() function.
This follows in the same vein as the other recent refactorings. With the machinery in place, list_cli, list_cgi, etc. are all replaced by one function list_sapi() taking a SAPI name as an argument.
-rw-r--r--src/php.eselect.in70
1 files changed, 24 insertions, 46 deletions
diff --git a/src/php.eselect.in b/src/php.eselect.in
index a377116..9a1d628 100644
--- a/src/php.eselect.in
+++ b/src/php.eselect.in
@@ -249,69 +249,47 @@ check_module() {
## Actual actions
-list_apache2() {
- local targets
- local a
- targets=( $(find_sapi_targets apache2) )
- a=$(get_sapi_active_target apache2)
+# Perform the "list" action for the given SAPI.
+#
+# INPUT:
+#
+# The SAPI name.
+#
+# OUTPUT:
+#
+# A numbered and decorated list of targets for the given SAPI.
+#
+list_sapi() {
+ local sapi="${1}"
+ local targets=( $(find_sapi_targets "${sapi}") )
+ local active=$(get_sapi_active_target "${sapi}")
+
for (( i = 0; i < ${#targets[@]}; i++ )) ; do
- if [[ $a == ${targets[i]} ]] ; then
+ if [[ $active == ${targets[i]} ]] ; then
targets[i]=$(highlight_marker "${targets[i]}")
fi
done
write_numbered_list -m "(none found)" "${targets[@]}"
}
+list_apache2() {
+ list_sapi apache2
+}
+
list_cli() {
- local targets
- local a
- targets=( $(find_sapi_targets cli) )
- a=$(get_sapi_active_target cli)
- for (( i = 0; i < ${#targets[@]}; i++ )) ; do
- if [[ $a == ${targets[i]} ]] ; then
- targets[i]=$(highlight_marker "${targets[i]}")
- fi
- done
- write_numbered_list -m "(none found)" "${targets[@]}"
+ list_sapi cli
}
list_cgi() {
- local targets
- local a
- targets=( $(find_sapi_targets cgi) )
- a=$(get_sapi_active_target cgi)
- for (( i = 0; i < ${#targets[@]}; i++ )) ; do
- if [[ $a == ${targets[i]} ]] ; then
- targets[i]=$(highlight_marker "${targets[i]}")
- fi
- done
- write_numbered_list -m "(none found)" "${targets[@]}"
+ list_sapi cgi
}
list_fpm() {
- local targets
- local a
- targets=( $(find_sapi_targets fpm) )
- a=$(get_sapi_active_target fpm)
- for (( i = 0; i < ${#targets[@]}; i++ )) ; do
- if [[ $a == ${targets[i]} ]] ; then
- targets[i]=$(highlight_marker "${targets[i]}")
- fi
- done
- write_numbered_list -m "(none found)" "${targets[@]}"
+ list_sapi fpm
}
list_phpdbg() {
- local targets
- local a
- targets=( $(find_sapi_targets dbg) )
- a=$(get_sapi_active_target dbg)
- for (( i = 0; i < ${#targets[@]}; i++ )) ; do
- if [[ $a == ${targets[i]} ]] ; then
- targets[i]=$(highlight_marker "${targets[i]}")
- fi
- done
- write_numbered_list -m "(none found)" "${targets[@]}"
+ list_sapi dbg
}
set_apache2() {