10
10
image:: DynamicImage ,
11
11
std:: { convert:: From , env, str:: FromStr } ,
12
12
strum:: IntoEnumIterator ,
13
+ term_size,
13
14
} ;
14
15
16
+ const MAX_TERM_WIDTH : usize = 95 ;
17
+
15
18
pub struct Cli {
16
19
pub repo_path : String ,
17
20
pub ascii_input : Option < String > ,
@@ -94,7 +97,7 @@ impl Cli {
94
97
. help ( "Takes a non-empty STRING as input to replace the ASCII logo." )
95
98
. long_help (
96
99
"Takes a non-empty STRING as input to replace the ASCII logo. \
97
- It is possible to pass a generated STRING by command substitution. \
100
+ It is possible to pass a generated STRING by command substitution. \n \
98
101
For example:\n \
99
102
'--ascii-input \" $(fortune | cowsay -W 25)\" '"
100
103
)
@@ -129,7 +132,7 @@ impl Cli {
129
132
. help ( "Changes the text colors (X X X...)." )
130
133
. long_help (
131
134
"Changes the text colors (X X X...). \
132
- Goes in order of title, ~, underline, subtitle, colon, and info. \
135
+ Goes in order of title, ~, underline, subtitle, colon, and info. \n \
133
136
For example:\n \
134
137
'--text-colors 9 10 11 12 13 14'"
135
138
)
@@ -218,19 +221,26 @@ impl Cli {
218
221
. help ( "Ignore all files & directories matching EXCLUDE." ) ,
219
222
)
220
223
. arg (
221
- Arg :: with_name ( "off" )
222
- . long ( "off" )
223
- . help ( "Only shows the info lines." )
224
- . conflicts_with_all ( & [ "image" , "ascii-language" , "ascii-input" ] ) ,
225
- ) . get_matches ( ) ;
224
+ Arg :: with_name ( "hide-logo" )
225
+ . long ( "hide-logo" )
226
+ . value_name ( "WHEN" )
227
+ . takes_value ( true )
228
+ . possible_values ( & [ "auto" , "always" ] )
229
+ . default_value ( "always" )
230
+ . hide_default_value ( true )
231
+ . help ( "Specify when to hide the logo (auto, *always*)." )
232
+ . long_help (
233
+ "Specify when to hide the logo (auto, *always*). \n \
234
+ If set to auto, the logo will be hidden if the terminal's width < 95."
235
+ )
236
+ ) . get_matches ( ) ;
226
237
238
+ let true_color = cli_utils:: is_truecolor_terminal ( ) ;
227
239
let no_bold = matches. is_present ( "no-bold" ) ;
228
240
let no_merges = matches. is_present ( "no-merge-commits" ) ;
229
241
let no_color_palette = matches. is_present ( "no-color-palette" ) ;
230
242
let print_languages = matches. is_present ( "languages" ) ;
231
243
let print_package_managers = matches. is_present ( "package-managers" ) ;
232
- let art_off = matches. is_present ( "off" ) ;
233
- let true_color = cli_utils:: is_truecolor_terminal ( ) ;
234
244
235
245
let fields_to_hide: Vec < String > = if let Some ( values) = matches. values_of ( "disable-fields" )
236
246
{
@@ -239,6 +249,18 @@ impl Cli {
239
249
Vec :: new ( )
240
250
} ;
241
251
252
+ let art_off = match matches. value_of ( "hide-logo" ) {
253
+ Some ( "always" ) => true ,
254
+ Some ( "auto" ) => {
255
+ if let Some ( ( width, _) ) = term_size:: dimensions_stdout ( ) {
256
+ width < MAX_TERM_WIDTH
257
+ } else {
258
+ false
259
+ }
260
+ }
261
+ _ => unreachable ! ( "other values for --hide-logo are not allowed" ) ,
262
+ } ;
263
+
242
264
let image = if let Some ( image_path) = matches. value_of ( "image" ) {
243
265
Some ( image:: open ( image_path) . chain_err ( || "Could not load the specified image" ) ?)
244
266
} else {
0 commit comments