@@ -91,30 +91,33 @@ cli_info(FeatureFlags) ->
9191% % @param Options Options to tune what is displayed and how.
9292
9393info (Options ) ->
94+ UseColors = use_colors (Options ),
9495 % % Two tables: one for stable feature flags, one for experimental ones.
9596 StableFF = rabbit_feature_flags :list (all , stable ),
9697 case maps :size (StableFF ) of
9798 0 ->
9899 ok ;
99100 _ ->
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 )]),
103105 info (StableFF , Options )
104106 end ,
105107 ExpFF = rabbit_feature_flags :list (all , experimental ),
106108 case maps :size (ExpFF ) of
107109 0 ->
108110 ok ;
109111 _ ->
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 )]),
113116 info (ExpFF , Options )
114117 end ,
115118 case maps :size (StableFF ) + maps :size (ExpFF ) of
116119 0 -> ok ;
117- _ -> state_legend ()
120+ _ -> state_legend (Options )
118121 end .
119122
120123-spec info (rabbit_feature_flags :feature_flags (), info_options ()) -> ok .
@@ -127,15 +130,8 @@ info(Options) ->
127130
128131info (FeatureFlags , Options ) ->
129132 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 ),
139135 % % Table columns:
140136 % % | Name | State | Provided by | Description
141137 % %
@@ -182,10 +178,12 @@ info(FeatureFlags, Options) ->
182178 " ~s : ~s~s~s " ,
183179 [Node ,
184180 rabbit_pretty_stdout :
185- ascii_color (LabelColor ),
181+ ascii_color (LabelColor ,
182+ UseColors ),
186183 Label ,
187184 rabbit_pretty_stdout :
188- ascii_color (default )]),
185+ ascii_color (default ,
186+ UseColors )]),
189187 [empty ,
190188 empty ,
191189 empty ,
@@ -209,7 +207,14 @@ info(FeatureFlags, Options) ->
209207 UseColors ,
210208 UseLines ).
211209
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 ),
213218 io :format (
214219 " ~n "
215220 " Possible states:~n "
@@ -218,12 +223,12 @@ state_legend() ->
218223 " ~s Unavailable~s : The feature flag cannot be enabled because one or "
219224 " more nodes do not support it~n "
220225 " ~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 )]).
227232
228233-spec format_error (any ()) -> string ().
229234% % @doc
0 commit comments