1 |
commit: a3091c3b9dcae38cc1b6a78f8f963e2cbc3144be |
2 |
Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Dec 20 00:06:47 2015 +0000 |
4 |
Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Dec 20 00:06:47 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=a3091c3b |
7 |
|
8 |
Consolidate all list_foo actions into one new list_sapi() function. |
9 |
|
10 |
This follows in the same vein as the other recent refactorings. With |
11 |
the machinery in place, list_cli, list_cgi, etc. are all replaced by |
12 |
one function list_sapi() taking a SAPI name as an argument. |
13 |
|
14 |
src/php.eselect.in | 70 +++++++++++++++++++----------------------------------- |
15 |
1 file changed, 24 insertions(+), 46 deletions(-) |
16 |
|
17 |
diff --git a/src/php.eselect.in b/src/php.eselect.in |
18 |
index a377116..9a1d628 100644 |
19 |
--- a/src/php.eselect.in |
20 |
+++ b/src/php.eselect.in |
21 |
@@ -249,69 +249,47 @@ check_module() { |
22 |
|
23 |
## Actual actions |
24 |
|
25 |
-list_apache2() { |
26 |
- local targets |
27 |
- local a |
28 |
- targets=( $(find_sapi_targets apache2) ) |
29 |
- a=$(get_sapi_active_target apache2) |
30 |
+# Perform the "list" action for the given SAPI. |
31 |
+# |
32 |
+# INPUT: |
33 |
+# |
34 |
+# The SAPI name. |
35 |
+# |
36 |
+# OUTPUT: |
37 |
+# |
38 |
+# A numbered and decorated list of targets for the given SAPI. |
39 |
+# |
40 |
+list_sapi() { |
41 |
+ local sapi="${1}" |
42 |
+ local targets=( $(find_sapi_targets "${sapi}") ) |
43 |
+ local active=$(get_sapi_active_target "${sapi}") |
44 |
+ |
45 |
for (( i = 0; i < ${#targets[@]}; i++ )) ; do |
46 |
- if [[ $a == ${targets[i]} ]] ; then |
47 |
+ if [[ $active == ${targets[i]} ]] ; then |
48 |
targets[i]=$(highlight_marker "${targets[i]}") |
49 |
fi |
50 |
done |
51 |
write_numbered_list -m "(none found)" "${targets[@]}" |
52 |
} |
53 |
|
54 |
+list_apache2() { |
55 |
+ list_sapi apache2 |
56 |
+} |
57 |
+ |
58 |
list_cli() { |
59 |
- local targets |
60 |
- local a |
61 |
- targets=( $(find_sapi_targets cli) ) |
62 |
- a=$(get_sapi_active_target cli) |
63 |
- for (( i = 0; i < ${#targets[@]}; i++ )) ; do |
64 |
- if [[ $a == ${targets[i]} ]] ; then |
65 |
- targets[i]=$(highlight_marker "${targets[i]}") |
66 |
- fi |
67 |
- done |
68 |
- write_numbered_list -m "(none found)" "${targets[@]}" |
69 |
+ list_sapi cli |
70 |
} |
71 |
|
72 |
list_cgi() { |
73 |
- local targets |
74 |
- local a |
75 |
- targets=( $(find_sapi_targets cgi) ) |
76 |
- a=$(get_sapi_active_target cgi) |
77 |
- for (( i = 0; i < ${#targets[@]}; i++ )) ; do |
78 |
- if [[ $a == ${targets[i]} ]] ; then |
79 |
- targets[i]=$(highlight_marker "${targets[i]}") |
80 |
- fi |
81 |
- done |
82 |
- write_numbered_list -m "(none found)" "${targets[@]}" |
83 |
+ list_sapi cgi |
84 |
} |
85 |
|
86 |
list_fpm() { |
87 |
- local targets |
88 |
- local a |
89 |
- targets=( $(find_sapi_targets fpm) ) |
90 |
- a=$(get_sapi_active_target fpm) |
91 |
- for (( i = 0; i < ${#targets[@]}; i++ )) ; do |
92 |
- if [[ $a == ${targets[i]} ]] ; then |
93 |
- targets[i]=$(highlight_marker "${targets[i]}") |
94 |
- fi |
95 |
- done |
96 |
- write_numbered_list -m "(none found)" "${targets[@]}" |
97 |
+ list_sapi fpm |
98 |
} |
99 |
|
100 |
list_phpdbg() { |
101 |
- local targets |
102 |
- local a |
103 |
- targets=( $(find_sapi_targets dbg) ) |
104 |
- a=$(get_sapi_active_target dbg) |
105 |
- for (( i = 0; i < ${#targets[@]}; i++ )) ; do |
106 |
- if [[ $a == ${targets[i]} ]] ; then |
107 |
- targets[i]=$(highlight_marker "${targets[i]}") |
108 |
- fi |
109 |
- done |
110 |
- write_numbered_list -m "(none found)" "${targets[@]}" |
111 |
+ list_sapi dbg |
112 |
} |
113 |
|
114 |
set_apache2() { |