Skip to content

Commit f34303b

Browse files
committed
update rustfmt
1 parent 23507b0 commit f34303b

21 files changed

+2155
-2015
lines changed

Diff for: .rustfmt.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1+
hard_tabs = true
12
newline_style = "Unix"
2-
# The "Default" setting has a heuristic which splits lines too aggresively.
3-
use_small_heuristics = "Max"

Diff for: src/cli.rs

+169-163
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,42 @@ use strum::IntoEnumIterator;
1515
const MAX_TERM_WIDTH: usize = 95;
1616

1717
pub struct Config {
18-
pub repo_path: String,
19-
pub ascii_input: Option<String>,
20-
pub ascii_language: Option<Language>,
21-
pub ascii_colors: Vec<String>,
22-
pub disabled_fields: InfoFieldOff,
23-
pub no_bold: bool,
24-
pub image: Option<DynamicImage>,
25-
pub image_backend: Option<Box<dyn ImageBackend>>,
26-
pub image_color_resolution: usize,
27-
pub no_merges: bool,
28-
pub no_color_palette: bool,
29-
pub number_of_authors: usize,
30-
pub ignored_directories: Vec<String>,
31-
pub bot_regex_pattern: Option<Regex>,
32-
pub print_languages: bool,
33-
pub print_package_managers: bool,
34-
pub output: Option<SerializationFormat>,
35-
pub true_color: bool,
36-
pub art_off: bool,
37-
pub text_colors: Vec<String>,
38-
pub iso_time: bool,
39-
pub show_email: bool,
40-
pub include_hidden: bool,
41-
pub language_types: Vec<LanguageType>,
18+
pub repo_path: String,
19+
pub ascii_input: Option<String>,
20+
pub ascii_language: Option<Language>,
21+
pub ascii_colors: Vec<String>,
22+
pub disabled_fields: InfoFieldOff,
23+
pub no_bold: bool,
24+
pub image: Option<DynamicImage>,
25+
pub image_backend: Option<Box<dyn ImageBackend>>,
26+
pub image_color_resolution: usize,
27+
pub no_merges: bool,
28+
pub no_color_palette: bool,
29+
pub number_of_authors: usize,
30+
pub ignored_directories: Vec<String>,
31+
pub bot_regex_pattern: Option<Regex>,
32+
pub print_languages: bool,
33+
pub print_package_managers: bool,
34+
pub output: Option<SerializationFormat>,
35+
pub true_color: bool,
36+
pub art_off: bool,
37+
pub text_colors: Vec<String>,
38+
pub iso_time: bool,
39+
pub show_email: bool,
40+
pub include_hidden: bool,
41+
pub language_types: Vec<LanguageType>,
4242
}
4343

4444
impl Config {
45-
pub fn new() -> Result<Self> {
46-
#[cfg(not(windows))]
47-
let possible_backends = ["kitty", "iterm", "sixel"];
48-
#[cfg(windows)]
49-
let possible_backends = [];
50-
let color_values =
51-
&["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"];
52-
let matches = App::new(crate_name!())
45+
pub fn new() -> Result<Self> {
46+
#[cfg(not(windows))]
47+
let possible_backends = ["kitty", "iterm", "sixel"];
48+
#[cfg(windows)]
49+
let possible_backends = [];
50+
let color_values = &[
51+
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
52+
];
53+
let matches = App::new(crate_name!())
5354
.version(crate_version!())
5455
.about(crate_description!())
5556
.setting(AppSettings::ColoredHelp)
@@ -295,168 +296,173 @@ impl Config {
295296
)
296297
.get_matches();
297298

298-
let true_color = match matches.value_of("true-color") {
299-
Some("always") => true,
300-
Some("never") => false,
301-
Some("auto") => is_truecolor_terminal(),
302-
_ => unreachable!(),
303-
};
299+
let true_color = match matches.value_of("true-color") {
300+
Some("always") => true,
301+
Some("never") => false,
302+
Some("auto") => is_truecolor_terminal(),
303+
_ => unreachable!(),
304+
};
304305

305-
let no_bold = matches.is_present("no-bold");
306-
let no_merges = matches.is_present("no-merges");
307-
let no_color_palette = matches.is_present("no-palette");
308-
let print_languages = matches.is_present("languages");
309-
let print_package_managers = matches.is_present("package-managers");
310-
let iso_time = matches.is_present("isotime");
311-
let show_email = matches.is_present("email");
312-
let include_hidden = matches.is_present("hidden");
306+
let no_bold = matches.is_present("no-bold");
307+
let no_merges = matches.is_present("no-merges");
308+
let no_color_palette = matches.is_present("no-palette");
309+
let print_languages = matches.is_present("languages");
310+
let print_package_managers = matches.is_present("package-managers");
311+
let iso_time = matches.is_present("isotime");
312+
let show_email = matches.is_present("email");
313+
let include_hidden = matches.is_present("hidden");
313314

314-
let output = matches.value_of("output").map(SerializationFormat::from_str).transpose()?;
315+
let output = matches
316+
.value_of("output")
317+
.map(SerializationFormat::from_str)
318+
.transpose()?;
315319

316-
let fields_to_hide: Vec<String> = if let Some(values) = matches.values_of("disable-fields")
317-
{
318-
values.map(String::from).collect()
319-
} else {
320-
Vec::new()
321-
};
320+
let fields_to_hide: Vec<String> = if let Some(values) = matches.values_of("disable-fields")
321+
{
322+
values.map(String::from).collect()
323+
} else {
324+
Vec::new()
325+
};
322326

323-
let disabled_fields = InfoFieldOff::new(fields_to_hide)?;
327+
let disabled_fields = InfoFieldOff::new(fields_to_hide)?;
324328

325-
let art_off = match matches.value_of("show-logo") {
326-
Some("always") => false,
327-
Some("never") => true,
328-
Some("auto") => {
329-
if let Some((width, _)) = term_size::dimensions_stdout() {
330-
width < MAX_TERM_WIDTH
331-
} else {
332-
false
333-
}
334-
}
335-
_ => unreachable!(),
336-
};
329+
let art_off = match matches.value_of("show-logo") {
330+
Some("always") => false,
331+
Some("never") => true,
332+
Some("auto") => {
333+
if let Some((width, _)) = term_size::dimensions_stdout() {
334+
width < MAX_TERM_WIDTH
335+
} else {
336+
false
337+
}
338+
}
339+
_ => unreachable!(),
340+
};
337341

338-
let image = if let Some(image_path) = matches.value_of("image") {
339-
Some(image::open(image_path).with_context(|| "Could not load the specified image")?)
340-
} else {
341-
None
342-
};
342+
let image = if let Some(image_path) = matches.value_of("image") {
343+
Some(image::open(image_path).with_context(|| "Could not load the specified image")?)
344+
} else {
345+
None
346+
};
343347

344-
let image_backend = if image.is_some() {
345-
if let Some(backend_name) = matches.value_of("image-backend") {
346-
image_backends::get_image_backend(backend_name)
347-
} else {
348-
image_backends::get_best_backend()
349-
}
350-
} else {
351-
None
352-
};
348+
let image_backend = if image.is_some() {
349+
if let Some(backend_name) = matches.value_of("image-backend") {
350+
image_backends::get_image_backend(backend_name)
351+
} else {
352+
image_backends::get_best_backend()
353+
}
354+
} else {
355+
None
356+
};
353357

354-
let image_color_resolution = if let Some(value) = matches.value_of("color-resolution") {
355-
usize::from_str(value)?
356-
} else {
357-
16
358-
};
358+
let image_color_resolution = if let Some(value) = matches.value_of("color-resolution") {
359+
usize::from_str(value)?
360+
} else {
361+
16
362+
};
359363

360-
let repo_path = matches
361-
.value_of("input")
362-
.map(String::from)
363-
.with_context(|| "Failed to parse input directory")?;
364+
let repo_path = matches
365+
.value_of("input")
366+
.map(String::from)
367+
.with_context(|| "Failed to parse input directory")?;
364368

365-
let ascii_input = matches.value_of("ascii-input").map(String::from);
369+
let ascii_input = matches.value_of("ascii-input").map(String::from);
366370

367-
let ascii_language = matches
368-
.value_of("ascii-language")
369-
.map(|ascii_language| Language::from_str(&ascii_language.to_lowercase()).unwrap());
371+
let ascii_language = matches
372+
.value_of("ascii-language")
373+
.map(|ascii_language| Language::from_str(&ascii_language.to_lowercase()).unwrap());
370374

371-
let ascii_colors = if let Some(values) = matches.values_of("ascii-colors") {
372-
values.map(String::from).collect()
373-
} else {
374-
Vec::new()
375-
};
375+
let ascii_colors = if let Some(values) = matches.values_of("ascii-colors") {
376+
values.map(String::from).collect()
377+
} else {
378+
Vec::new()
379+
};
376380

377-
let text_colors = if let Some(values) = matches.values_of("text-colors") {
378-
values.map(String::from).collect()
379-
} else {
380-
Vec::new()
381-
};
381+
let text_colors = if let Some(values) = matches.values_of("text-colors") {
382+
values.map(String::from).collect()
383+
} else {
384+
Vec::new()
385+
};
382386

383-
let number_of_authors: usize = matches.value_of("authors-number").unwrap().parse()?;
387+
let number_of_authors: usize = matches.value_of("authors-number").unwrap().parse()?;
384388

385-
let ignored_directories =
386-
if let Some(user_ignored_directories) = matches.values_of("exclude") {
387-
user_ignored_directories.map(String::from).collect()
388-
} else {
389-
Vec::new()
390-
};
389+
let ignored_directories =
390+
if let Some(user_ignored_directories) = matches.values_of("exclude") {
391+
user_ignored_directories.map(String::from).collect()
392+
} else {
393+
Vec::new()
394+
};
391395

392-
let bot_regex_pattern = matches.is_present("no-bots").then(|| {
393-
matches
394-
.value_of("no-bots")
395-
.map_or(Regex::from_str(r"\[bot\]").unwrap(), |s| Regex::from_str(s).unwrap())
396-
});
396+
let bot_regex_pattern = matches.is_present("no-bots").then(|| {
397+
matches
398+
.value_of("no-bots")
399+
.map_or(Regex::from_str(r"\[bot\]").unwrap(), |s| {
400+
Regex::from_str(s).unwrap()
401+
})
402+
});
397403

398-
let language_types: Vec<LanguageType> = if let Some(values) = matches.values_of("type") {
399-
values.map(|t| LanguageType::from_str(t).unwrap()).collect()
400-
} else {
401-
vec![LanguageType::Programming, LanguageType::Markup]
402-
};
404+
let language_types: Vec<LanguageType> = if let Some(values) = matches.values_of("type") {
405+
values.map(|t| LanguageType::from_str(t).unwrap()).collect()
406+
} else {
407+
vec![LanguageType::Programming, LanguageType::Markup]
408+
};
403409

404-
Ok(Config {
405-
repo_path,
406-
ascii_input,
407-
ascii_language,
408-
ascii_colors,
409-
disabled_fields,
410-
no_bold,
411-
image,
412-
image_backend,
413-
image_color_resolution,
414-
no_merges,
415-
no_color_palette,
416-
number_of_authors,
417-
ignored_directories,
418-
bot_regex_pattern,
419-
print_languages,
420-
print_package_managers,
421-
output,
422-
true_color,
423-
art_off,
424-
text_colors,
425-
iso_time,
426-
show_email,
427-
include_hidden,
428-
language_types,
429-
})
430-
}
410+
Ok(Config {
411+
repo_path,
412+
ascii_input,
413+
ascii_language,
414+
ascii_colors,
415+
disabled_fields,
416+
no_bold,
417+
image,
418+
image_backend,
419+
image_color_resolution,
420+
no_merges,
421+
no_color_palette,
422+
number_of_authors,
423+
ignored_directories,
424+
bot_regex_pattern,
425+
print_languages,
426+
print_package_managers,
427+
output,
428+
true_color,
429+
art_off,
430+
text_colors,
431+
iso_time,
432+
show_email,
433+
include_hidden,
434+
language_types,
435+
})
436+
}
431437
}
432438

433439
pub fn print_supported_languages() -> Result<()> {
434-
for l in Language::iter() {
435-
println!("{}", l);
436-
}
440+
for l in Language::iter() {
441+
println!("{}", l);
442+
}
437443

438-
Ok(())
444+
Ok(())
439445
}
440446

441447
pub fn print_supported_package_managers() -> Result<()> {
442-
for p in PackageManager::iter() {
443-
println!("{}", p);
444-
}
448+
for p in PackageManager::iter() {
449+
println!("{}", p);
450+
}
445451

446-
Ok(())
452+
Ok(())
447453
}
448454

449455
pub fn is_truecolor_terminal() -> bool {
450-
env::var("COLORTERM")
451-
.map(|colorterm| colorterm == "truecolor" || colorterm == "24bit")
452-
.unwrap_or(false)
456+
env::var("COLORTERM")
457+
.map(|colorterm| colorterm == "truecolor" || colorterm == "24bit")
458+
.unwrap_or(false)
453459
}
454460

455461
pub fn get_git_version() -> String {
456-
let version = Command::new("git").arg("--version").output();
462+
let version = Command::new("git").arg("--version").output();
457463

458-
match version {
459-
Ok(v) => String::from_utf8_lossy(&v.stdout).replace('\n', ""),
460-
Err(_) => String::new(),
461-
}
464+
match version {
465+
Ok(v) => String::from_utf8_lossy(&v.stdout).replace('\n', ""),
466+
Err(_) => String::new(),
467+
}
462468
}

0 commit comments

Comments
 (0)