Skip to content

Commit c72dbbe

Browse files
committed
Modified CLI (See full commit msg for details)
- --hide-logo no longer takes an argument - new flags --hide-logo and --show-logo force logo display - new flag --max-width allows the user to set the max width (default 95) - passing no flags will automatically decide if the logo should be shown Signed-off-by: Luke-zhang-04 <[email protected]>
1 parent 5762b15 commit c72dbbe

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

Diff for: src/onefetch/cli.rs

+29-8
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,31 @@ impl Cli {
218218
.takes_value(true)
219219
.help("Ignore all files & directories matching EXCLUDE."),
220220
)
221+
.arg(
222+
Arg::with_name("show-logo")
223+
.short("S")
224+
.long("show-logo")
225+
.takes_value(false)
226+
.help("If ASCII logo should be shown in all circumstances.")
227+
.conflicts_with("hide-logo")
228+
)
221229
.arg(
222230
Arg::with_name("hide-logo")
223231
.short("H")
224232
.long("hide-logo")
225-
.value_name("WIDTH_THRESHOLD")
233+
.takes_value(false)
234+
.help("If ASCII logo should be hidden in all circumstances.")
235+
.conflicts_with("show-logo")
236+
)
237+
.arg(
238+
Arg::with_name("max-width")
239+
.short("w")
240+
.long("max-width")
241+
.value_name("AMOUNT")
226242
.takes_value(true)
227243
.max_values(1)
228244
.default_value("95")
229-
.help("If ASCII logo should be hidden when terminal width is below WIDTH_THRESHOLD.")
245+
.help("If ASCII logo should be hidden when terminal width is below AMOUNT.")
230246
.validator(
231247
|t| {
232248
t.parse::<u32>()
@@ -242,9 +258,9 @@ impl Cli {
242258
let no_color_palette = matches.is_present("no-color-palette");
243259
let print_languages = matches.is_present("languages");
244260
let print_package_managers = matches.is_present("package-managers");
245-
let mut art_off = false;
261+
let mut art_off = matches.is_present("hide-logo") || !matches.is_present("show-logo");
246262
let true_color = cli_utils::is_truecolor_terminal();
247-
let max_term_size: usize = matches.value_of("hide-logo").unwrap().parse().unwrap();
263+
let max_term_size: usize = matches.value_of("max-width").unwrap().parse().unwrap();
248264

249265
let fields_to_hide: Vec<String> = if let Some(values) = matches.values_of("disable-fields")
250266
{
@@ -269,10 +285,15 @@ impl Cli {
269285
None
270286
};
271287

272-
if let Some((width, _)) = term_size::dimensions_stdout() {
273-
art_off = width <= max_term_size && matches.is_present("hide-logo");
274-
} else {
275-
std::eprintln!("{}", ("Could not get terminal width. ASCII art will be displayed."));
288+
if !matches.is_present("hide-logo") && !matches.is_present("show-logo") {
289+
if let Some((width, _)) = term_size::dimensions_stdout() {
290+
art_off = width <= max_term_size;
291+
} else {
292+
std::eprintln!(
293+
"{}",
294+
("Could not get terminal width. ASCII art will be displayed.")
295+
);
296+
}
276297
}
277298

278299
if image.is_some() && image_backend.is_none() {

0 commit comments

Comments
 (0)