@@ -91,30 +91,33 @@ cli_info(FeatureFlags) ->
91
91
% % @param Options Options to tune what is displayed and how.
92
92
93
93
info (Options ) ->
94
+ UseColors = use_colors (Options ),
94
95
% % Two tables: one for stable feature flags, one for experimental ones.
95
96
StableFF = rabbit_feature_flags :list (all , stable ),
96
97
case maps :size (StableFF ) of
97
98
0 ->
98
99
ok ;
99
100
_ ->
100
- io :format (" ~n~s ## Stable feature flags:~s~n " ,
101
- [rabbit_pretty_stdout :ascii_color (bright_white ),
102
- rabbit_pretty_stdout :ascii_color (default )]),
101
+ io :format (
102
+ " ~n~s ## Stable feature flags:~s~n " ,
103
+ [rabbit_pretty_stdout :ascii_color (bright_white , UseColors ),
104
+ rabbit_pretty_stdout :ascii_color (default , UseColors )]),
103
105
info (StableFF , Options )
104
106
end ,
105
107
ExpFF = rabbit_feature_flags :list (all , experimental ),
106
108
case maps :size (ExpFF ) of
107
109
0 ->
108
110
ok ;
109
111
_ ->
110
- io :format (" ~n~s ## Experimental feature flags:~s~n " ,
111
- [rabbit_pretty_stdout :ascii_color (bright_white ),
112
- rabbit_pretty_stdout :ascii_color (default )]),
112
+ io :format (
113
+ " ~n~s ## Experimental feature flags:~s~n " ,
114
+ [rabbit_pretty_stdout :ascii_color (bright_white , UseColors ),
115
+ rabbit_pretty_stdout :ascii_color (default , UseColors )]),
113
116
info (ExpFF , Options )
114
117
end ,
115
118
case maps :size (StableFF ) + maps :size (ExpFF ) of
116
119
0 -> ok ;
117
- _ -> state_legend ()
120
+ _ -> state_legend (Options )
118
121
end .
119
122
120
123
-spec info (rabbit_feature_flags :feature_flags (), info_options ()) -> ok .
@@ -127,15 +130,8 @@ info(Options) ->
127
130
128
131
info (FeatureFlags , Options ) ->
129
132
Verbose = maps :get (verbose , Options , 0 ),
130
- IsaTty = case os :getenv (" TERM" ) of
131
- % % We don't have access to isatty(3), so let's
132
- % % assume that is $TERM is defined, we can use
133
- % % colors and drawing characters.
134
- false -> false ;
135
- _ -> true
136
- end ,
137
- UseColors = maps :get (color , Options , IsaTty ),
138
- UseLines = maps :get (lines , Options , IsaTty ),
133
+ UseColors = use_colors (Options ),
134
+ UseLines = use_lines (Options ),
139
135
% % Table columns:
140
136
% % | Name | State | Provided by | Description
141
137
% %
@@ -182,10 +178,12 @@ info(FeatureFlags, Options) ->
182
178
" ~s : ~s~s~s " ,
183
179
[Node ,
184
180
rabbit_pretty_stdout :
185
- ascii_color (LabelColor ),
181
+ ascii_color (LabelColor ,
182
+ UseColors ),
186
183
Label ,
187
184
rabbit_pretty_stdout :
188
- ascii_color (default )]),
185
+ ascii_color (default ,
186
+ UseColors )]),
189
187
[empty ,
190
188
empty ,
191
189
empty ,
@@ -209,7 +207,14 @@ info(FeatureFlags, Options) ->
209
207
UseColors ,
210
208
UseLines ).
211
209
212
- state_legend () ->
210
+ use_colors (Options ) ->
211
+ maps :get (color , Options , rabbit_pretty_stdout :isatty ()).
212
+
213
+ use_lines (Options ) ->
214
+ maps :get (lines , Options , rabbit_pretty_stdout :isatty ()).
215
+
216
+ state_legend (Options ) ->
217
+ UseColors = use_colors (Options ),
213
218
io :format (
214
219
" ~n "
215
220
" Possible states:~n "
@@ -218,12 +223,12 @@ state_legend() ->
218
223
" ~s Unavailable~s : The feature flag cannot be enabled because one or "
219
224
" more nodes do not support it~n "
220
225
" ~n " ,
221
- [rabbit_pretty_stdout :ascii_color (green ),
222
- rabbit_pretty_stdout :ascii_color (default ),
223
- rabbit_pretty_stdout :ascii_color (yellow ),
224
- rabbit_pretty_stdout :ascii_color (default ),
225
- rabbit_pretty_stdout :ascii_color (red_bg ),
226
- rabbit_pretty_stdout :ascii_color (default )]).
226
+ [rabbit_pretty_stdout :ascii_color (green , UseColors ),
227
+ rabbit_pretty_stdout :ascii_color (default , UseColors ),
228
+ rabbit_pretty_stdout :ascii_color (yellow , UseColors ),
229
+ rabbit_pretty_stdout :ascii_color (default , UseColors ),
230
+ rabbit_pretty_stdout :ascii_color (red_bg , UseColors ),
231
+ rabbit_pretty_stdout :ascii_color (default , UseColors )]).
227
232
228
233
-spec format_error (any ()) -> string ().
229
234
% % @doc
0 commit comments