From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 19D661384B4 for ; Sun, 20 Dec 2015 00:17:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1475C21C09F; Sun, 20 Dec 2015 00:17:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0D39321C067 for ; Sun, 20 Dec 2015 00:17:43 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2CD7C340814 for ; Sun, 20 Dec 2015 00:17:42 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BF840CF0 for ; Sun, 20 Dec 2015 00:17:38 +0000 (UTC) From: "Michael Orlitzky" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michael Orlitzky" Message-ID: <1450570007.a3091c3b9dcae38cc1b6a78f8f963e2cbc3144be.mjo@gentoo> Subject: [gentoo-commits] proj/eselect-php:master commit in: src/ X-VCS-Repository: proj/eselect-php X-VCS-Files: src/php.eselect.in X-VCS-Directories: src/ X-VCS-Committer: mjo X-VCS-Committer-Name: Michael Orlitzky X-VCS-Revision: a3091c3b9dcae38cc1b6a78f8f963e2cbc3144be X-VCS-Branch: master Date: Sun, 20 Dec 2015 00:17:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: dd705310-8926-4c6c-a641-e92184b19da3 X-Archives-Hash: 9b996079d94c3cb10c0b53a6c16b20ed commit: a3091c3b9dcae38cc1b6a78f8f963e2cbc3144be Author: Michael Orlitzky gentoo org> AuthorDate: Sun Dec 20 00:06:47 2015 +0000 Commit: Michael Orlitzky gentoo org> CommitDate: Sun Dec 20 00:06:47 2015 +0000 URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=a3091c3b 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. src/php.eselect.in | 70 +++++++++++++++++++----------------------------------- 1 file 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() {