1 |
Author: ulm |
2 |
Date: 2011-10-28 23:43:52 +0000 (Fri, 28 Oct 2011) |
3 |
New Revision: 854 |
4 |
|
5 |
Modified: |
6 |
trunk/ChangeLog |
7 |
trunk/NEWS |
8 |
trunk/bin/eselect.in |
9 |
trunk/man/eselect.1 |
10 |
trunk/misc/eselect.bashcomp |
11 |
Log: |
12 |
New global option --colour=<yes|no|auto>. |
13 |
|
14 |
Modified: trunk/ChangeLog |
15 |
=================================================================== |
16 |
--- trunk/ChangeLog 2011-10-28 23:12:56 UTC (rev 853) |
17 |
+++ trunk/ChangeLog 2011-10-28 23:43:52 UTC (rev 854) |
18 |
@@ -1,3 +1,13 @@ |
19 |
+2011-10-29 Ulrich Mueller <ulm@g.o> |
20 |
+ |
21 |
+ * bin/eselect.in: New option --colour=<yes|no|auto>, similar to |
22 |
+ the same option in emerge and ls commands. Spelling --color is |
23 |
+ recognised too. |
24 |
+ (es_do_list_options): Update accordingly. |
25 |
+ (ESELECT_OPTIONS): Remove unused global variable. |
26 |
+ * man/eselect.1: Document the --colour option. |
27 |
+ * misc/eselect.bashcomp (_eselect): Update. |
28 |
+ |
29 |
2011-10-27 Ulrich Mueller <ulm@g.o> |
30 |
|
31 |
* modules/news.eselect (do_list): Display read/unread flags as one |
32 |
|
33 |
Modified: trunk/NEWS |
34 |
=================================================================== |
35 |
--- trunk/NEWS 2011-10-28 23:12:56 UTC (rev 853) |
36 |
+++ trunk/NEWS 2011-10-28 23:43:52 UTC (rev 854) |
37 |
@@ -4,6 +4,7 @@ |
38 |
New features: |
39 |
- The profile module supports profiles in overlays (bug #265264). |
40 |
- Changed output formatting in news module (bug #388233). |
41 |
+ - New global option --colour=<yes|no|auto>. |
42 |
|
43 |
1.2.18: |
44 |
Bug fixes: |
45 |
|
46 |
Modified: trunk/bin/eselect.in |
47 |
=================================================================== |
48 |
--- trunk/bin/eselect.in 2011-10-28 23:12:56 UTC (rev 853) |
49 |
+++ trunk/bin/eselect.in 2011-10-28 23:43:52 UTC (rev 854) |
50 |
@@ -41,9 +41,6 @@ |
51 |
ESELECT_BINARY_NAME="$0" |
52 |
ESELECT_KILL_TARGET="$$" |
53 |
|
54 |
-# Global options |
55 |
-ESELECT_OPTIONS="" |
56 |
- |
57 |
# Support variables for Gentoo Prefix |
58 |
EPREFIX="@EPREFIX@" |
59 |
EROOT="${ROOT}${EPREFIX}" |
60 |
@@ -112,8 +109,9 @@ |
61 |
# Display all recognized global options |
62 |
es_do_list_options() { |
63 |
write_list_start "Global options:" |
64 |
- write_kv_list_entry "--brief" "Make output shorter" |
65 |
- write_kv_list_entry "--no-color,--no-colour" "Disable coloured output" |
66 |
+ write_kv_list_entry "--brief" "Make output shorter" |
67 |
+ write_kv_list_entry "--colour=<yes|no|auto>" \ |
68 |
+ "Enable or disable colour output (default 'auto')" |
69 |
} |
70 |
|
71 |
# es_do_list_modules |
72 |
@@ -124,14 +122,6 @@ |
73 |
|
74 |
### main code ### |
75 |
|
76 |
-# enable colour output and get width of terminal iff stdout is a tty |
77 |
-if [[ -t 1 ]]; then |
78 |
- colours |
79 |
- init_columns |
80 |
-else |
81 |
- nocolours |
82 |
-fi |
83 |
- |
84 |
# figure out what the action is. we need to know whether we're |
85 |
# invoked as a something-config/something-update. |
86 |
action="" |
87 |
@@ -161,13 +151,20 @@ |
88 |
while [[ ${1##--} != "$1" ]]; do |
89 |
case ${1##--} in |
90 |
brief) |
91 |
- ESELECT_OPTIONS="${ESELECT_OPTIONS} brief" |
92 |
set_output_mode brief |
93 |
;; |
94 |
- no-colour|no-color) |
95 |
- ESELECT_OPTIONS="${ESELECT_OPTIONS} no-colour" |
96 |
- nocolours |
97 |
+ colour=*|color=*|colour|color) |
98 |
+ # accept all arguments that are valid for ls or emerge |
99 |
+ case ${1#*=} in |
100 |
+ yes|y|always|force|$1) colour=yes ;; |
101 |
+ no|n|never|none) colour=no ;; |
102 |
+ auto|tty|if-tty) colour="" ;; |
103 |
+ *) die -q "Invalid argument for ${1%%=*} option" ;; |
104 |
+ esac |
105 |
;; |
106 |
+ no-colour|no-color) # legacy option |
107 |
+ colour=no |
108 |
+ ;; |
109 |
help|version) |
110 |
action=${1##--} |
111 |
;; |
112 |
@@ -183,6 +180,15 @@ |
113 |
fi |
114 |
fi |
115 |
|
116 |
+# enable colour output and get width of terminal iff stdout is a tty |
117 |
+if [[ -t 1 ]]; then |
118 |
+ if [[ ${colour} = no ]]; then nocolours; else colours; fi |
119 |
+ init_columns |
120 |
+else |
121 |
+ if [[ ${colour} = yes ]]; then colours; else nocolours; fi |
122 |
+fi |
123 |
+unset colour |
124 |
+ |
125 |
if [[ -n ${action} ]]; then |
126 |
if is_function "es_do_${action//-/_}"; then |
127 |
[[ $# -gt 0 ]] && die -q "Too many parameters" |
128 |
|
129 |
Modified: trunk/man/eselect.1 |
130 |
=================================================================== |
131 |
--- trunk/man/eselect.1 2011-10-28 23:12:56 UTC (rev 853) |
132 |
+++ trunk/man/eselect.1 2011-10-28 23:43:52 UTC (rev 854) |
133 |
@@ -2,7 +2,7 @@ |
134 |
.\" Distributed under the terms of the GNU General Public License v2 |
135 |
.\" $Id$ |
136 |
.\" |
137 |
-.TH ESELECT 1 "August 2009" "Gentoo Linux" eselect |
138 |
+.TH ESELECT 1 "October 2011" "Gentoo Linux" eselect |
139 |
.SH NAME |
140 |
eselect \- Gentoo's multi\-purpose configuration and management tool |
141 |
.SH SYNOPSIS |
142 |
@@ -20,8 +20,18 @@ |
143 |
Set brief output mode, for use as input to other programs. |
144 |
(This is an experimental feature.) |
145 |
.TP |
146 |
-.BR \-\-no-color ", " \-\-no-colour |
147 |
-Disable coloured output. |
148 |
+.BI \-\-color= "mode, " \-\-colour= mode |
149 |
+Enable or disable colour output. |
150 |
+.I mode |
151 |
+can be |
152 |
+.BR yes , |
153 |
+.BR no , |
154 |
+or |
155 |
+.BR auto . |
156 |
+The default is |
157 |
+.BR auto , |
158 |
+for which colour output is enabled only if standard output is |
159 |
+connected to a terminal. |
160 |
.SH BUILT-INS |
161 |
.TP |
162 |
.B help |
163 |
|
164 |
Modified: trunk/misc/eselect.bashcomp |
165 |
=================================================================== |
166 |
--- trunk/misc/eselect.bashcomp 2011-10-28 23:12:56 UTC (rev 853) |
167 |
+++ trunk/misc/eselect.bashcomp 2011-10-28 23:43:52 UTC (rev 854) |
168 |
@@ -8,7 +8,7 @@ |
169 |
|
170 |
_eselect() { |
171 |
local cur sedcmd2 sedcmd3 possibles |
172 |
- local options="--brief --no-colour" |
173 |
+ local options="--brief --colour=" |
174 |
COMPREPLY=() |
175 |
cur="${COMP_WORDS[COMP_CWORD]}" |
176 |
sedcmd2='s/^ \([[:alnum:]-][[:alnum:]_-]*\)[[:space:],].*$/\1/p' |