Run cargo fmt

This commit is contained in:
Peltoche 2018-12-12 11:17:32 +01:00 committed by Pierre Peltier
parent 917498022e
commit 78f13841e8
5 changed files with 39 additions and 16 deletions

View file

@ -10,7 +10,8 @@ pub fn build_app() -> App<'static, 'static> {
.short("a") .short("a")
.long("all") .long("all")
.help("Do not ignore entries starting with ."), .help("Do not ignore entries starting with ."),
).arg( )
.arg(
Arg::with_name("color") Arg::with_name("color")
.long("color") .long("color")
.possible_value("always") .possible_value("always")
@ -18,27 +19,32 @@ pub fn build_app() -> App<'static, 'static> {
.possible_value("never") .possible_value("never")
.default_value("auto") .default_value("auto")
.help("When to use terminal colours"), .help("When to use terminal colours"),
).arg( )
.arg(
Arg::with_name("indicators") Arg::with_name("indicators")
.short("F") .short("F")
.long("classify") .long("classify")
.help("Append indicator (one of */=>@|) at the end of the file names"), .help("Append indicator (one of */=>@|) at the end of the file names"),
).arg( )
.arg(
Arg::with_name("long") Arg::with_name("long")
.short("l") .short("l")
.long("long") .long("long")
.help("Display extended file metadata as a table"), .help("Display extended file metadata as a table"),
).arg( )
.arg(
Arg::with_name("oneline") Arg::with_name("oneline")
.short("1") .short("1")
.long("oneline") .long("oneline")
.help("Display one entry per line"), .help("Display one entry per line"),
).arg( )
.arg(
Arg::with_name("recursive") Arg::with_name("recursive")
.short("R") .short("R")
.long("recursive") .long("recursive")
.help("Recurse into directories"), .help("Recurse into directories"),
).arg( )
.arg(
Arg::with_name("tree") Arg::with_name("tree")
.long("tree") .long("tree")
.help("Recurse into directories and present the result as a tree"), .help("Recurse into directories and present the result as a tree"),

View file

@ -91,7 +91,8 @@ impl Core {
} else { } else {
None None
} }
}).collect(); })
.collect();
self.run_inner(folder_dirs, depth); self.run_inner(folder_dirs, depth);
} else { } else {

View file

@ -91,7 +91,8 @@ impl Display {
.skip_while(|x| { .skip_while(|x| {
code_size += 1; code_size += 1;
char::is_numeric(*x) char::is_numeric(*x)
}).count(); })
.count();
nb_invisible_char += 6 + code_size; /* "[38;5;" + color number + "m" */ nb_invisible_char += 6 + code_size; /* "[38;5;" + color number + "m" */
} }

View file

@ -119,7 +119,8 @@ mod test {
.strftime("%Y%m%d%H%M.%S") .strftime("%Y%m%d%H%M.%S")
.unwrap() .unwrap()
.to_string(), .to_string(),
).arg(&file_path) )
.arg(&file_path)
.status() .status()
.unwrap() .unwrap()
.success(); .success();

View file

@ -1,5 +1,5 @@
use icon::Icons;
use color::{ColoredString, Colors, Elem}; use color::{ColoredString, Colors, Elem};
use icon::Icons;
use meta::filetype::FileType; use meta::filetype::FileType;
use std::cmp::{Ordering, PartialOrd}; use std::cmp::{Ordering, PartialOrd};
use std::path::Path; use std::path::Path;
@ -39,7 +39,9 @@ impl Name {
pub fn render(&self, colors: &Colors, icons: &Icons) -> ColoredString { pub fn render(&self, colors: &Colors, icons: &Icons) -> ColoredString {
let icon = icons.get(self); let icon = icons.get(self);
let mut content = String::with_capacity(icon.len() + ICON_SPACE.len() +self.name.len() + 3 /* spaces */); let mut content = String::with_capacity(
icon.len() + ICON_SPACE.len() + self.name.len() + 3, /* spaces */
);
content += icon; content += icon;
content += ICON_SPACE; content += ICON_SPACE;
@ -94,9 +96,9 @@ impl PartialEq for Name {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::Name; use super::Name;
use icon::Icons;
use ansi_term::Colour; use ansi_term::Colour;
use color::{Colors, Theme}; use color::{Colors, Theme};
use icon::Icons;
use meta::FileType; use meta::FileType;
use meta::Permissions; use meta::Permissions;
use std::fs::{self, File}; use std::fs::{self, File};
@ -119,7 +121,10 @@ mod test {
let file_type = FileType::new(&meta, &Permissions::from(&meta)); let file_type = FileType::new(&meta, &Permissions::from(&meta));
let name = Name::new(&file_path, file_type); let name = Name::new(&file_path, file_type);
assert_eq!(Colour::Fixed(184).paint(" file.txt"), name.render(&colors, &icons)); assert_eq!(
Colour::Fixed(184).paint(" file.txt"),
name.render(&colors, &icons)
);
} }
#[test] #[test]
@ -136,7 +141,10 @@ mod test {
let file_type = FileType::new(&meta, &Permissions::from(&meta)); let file_type = FileType::new(&meta, &Permissions::from(&meta));
let name = Name::new(&dir_path, file_type); let name = Name::new(&dir_path, file_type);
assert_eq!(Colour::Fixed(33).paint(" directory"), name.render(&colors, &icons)); assert_eq!(
Colour::Fixed(33).paint(" directory"),
name.render(&colors, &icons)
);
} }
#[test] #[test]
@ -159,7 +167,10 @@ mod test {
let file_type = FileType::new(&meta, &Permissions::from(&meta)); let file_type = FileType::new(&meta, &Permissions::from(&meta));
let name = Name::new(&symlink_path, file_type); let name = Name::new(&symlink_path, file_type);
assert_eq!(Colour::Fixed(44).paint(" target.tmp"), name.render(&colors, &icons)); assert_eq!(
Colour::Fixed(44).paint(" target.tmp"),
name.render(&colors, &icons)
);
} }
#[test] #[test]
@ -181,7 +192,10 @@ mod test {
let file_type = FileType::new(&meta, &Permissions::from(&meta)); let file_type = FileType::new(&meta, &Permissions::from(&meta));
let name = Name::new(&pipe_path, file_type); let name = Name::new(&pipe_path, file_type);
assert_eq!(Colour::Fixed(184).paint(" pipe.tmp"), name.render(&colors, &icons)); assert_eq!(
Colour::Fixed(184).paint(" pipe.tmp"),
name.render(&colors, &icons)
);
} }
#[test] #[test]