mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-01-30 17:18:37 +00:00
Start using new shorthand object field syntax
This commit is contained in:
parent
881438881f
commit
2f79b4db03
@ -55,10 +55,8 @@ pub struct Exa<'w, W: Write + 'w> {
|
|||||||
impl<'w, W: Write + 'w> Exa<'w, W> {
|
impl<'w, W: Write + 'w> Exa<'w, W> {
|
||||||
pub fn new<S>(args: &[S], writer: &'w mut W) -> Result<Exa<'w, W>, Misfire>
|
pub fn new<S>(args: &[S], writer: &'w mut W) -> Result<Exa<'w, W>, Misfire>
|
||||||
where S: AsRef<OsStr> {
|
where S: AsRef<OsStr> {
|
||||||
Options::getopts(args).map(move |(opts, args)| Exa {
|
Options::getopts(args).map(move |(options, args)| {
|
||||||
options: opts,
|
Exa { options, writer, args }
|
||||||
writer: writer,
|
|
||||||
args: args,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,10 +89,7 @@ impl RecurseOptions {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(RecurseOptions {
|
Ok(RecurseOptions { tree, max_depth })
|
||||||
tree: tree,
|
|
||||||
max_depth: max_depth,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether a directory of the given depth would be too deep.
|
/// Returns whether a directory of the given depth would be too deep.
|
||||||
|
@ -143,11 +143,7 @@ impl Options {
|
|||||||
let filter = FileFilter::deduce(matches)?;
|
let filter = FileFilter::deduce(matches)?;
|
||||||
let view = View::deduce(matches, filter.clone(), dir_action)?;
|
let view = View::deduce(matches, filter.clone(), dir_action)?;
|
||||||
|
|
||||||
Ok(Options {
|
Ok(Options { dir_action, view, filter })
|
||||||
dir_action: dir_action,
|
|
||||||
view: view,
|
|
||||||
filter: filter, // TODO: clone
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,9 +94,9 @@ impl View {
|
|||||||
|
|
||||||
if let Some(&width) = term_width.as_ref() {
|
if let Some(&width) = term_width.as_ref() {
|
||||||
let colours = match term_colours {
|
let colours = match term_colours {
|
||||||
TerminalColours::Always
|
TerminalColours::Always |
|
||||||
| TerminalColours::Automatic => Colours::colourful(colour_scale()),
|
TerminalColours::Automatic => Colours::colourful(colour_scale()),
|
||||||
TerminalColours::Never => Colours::plain(),
|
TerminalColours::Never => Colours::plain(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches.opt_present("oneline") {
|
if matches.opt_present("oneline") {
|
||||||
@ -104,12 +104,7 @@ impl View {
|
|||||||
Err(Useless("across", true, "oneline"))
|
Err(Useless("across", true, "oneline"))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let lines = Lines {
|
Ok(View::Lines(Lines { colours, classify }))
|
||||||
colours: colours,
|
|
||||||
classify: classify,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(View::Lines(lines))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if matches.opt_present("tree") {
|
else if matches.opt_present("tree") {
|
||||||
@ -160,28 +155,23 @@ impl View {
|
|||||||
Ok(View::Details(details))
|
Ok(View::Details(details))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let lines = Lines {
|
Ok(View::Lines(Lines { colours, classify }))
|
||||||
colours: colours,
|
|
||||||
classify: classify,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(View::Lines(lines))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches.opt_present("long") {
|
if matches.opt_present("long") {
|
||||||
let long_options = long()?;
|
let details = long()?;
|
||||||
|
|
||||||
if matches.opt_present("grid") {
|
if matches.opt_present("grid") {
|
||||||
match other_options_scan() {
|
match other_options_scan() {
|
||||||
Ok(View::Grid(grid)) => return Ok(View::GridDetails(GridDetails { grid: grid, details: long_options })),
|
Ok(View::Grid(grid)) => return Ok(View::GridDetails(GridDetails { grid, details })),
|
||||||
Ok(lines) => return Ok(lines),
|
Ok(lines) => return Ok(lines),
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Ok(View::Details(long_options));
|
return Ok(View::Details(details));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +303,7 @@ impl TimeTypes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if modified || created || accessed {
|
else if modified || created || accessed {
|
||||||
Ok(TimeTypes { accessed: accessed, modified: modified, created: created })
|
Ok(TimeTypes { accessed, modified, created })
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Ok(TimeTypes::default())
|
Ok(TimeTypes::default())
|
||||||
|
@ -316,14 +316,7 @@ impl Details {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let egg = Egg {
|
let egg = Egg { cells, xattrs, errors, dir, file };
|
||||||
cells: cells,
|
|
||||||
xattrs: xattrs,
|
|
||||||
errors: errors,
|
|
||||||
dir: dir,
|
|
||||||
file: file,
|
|
||||||
};
|
|
||||||
|
|
||||||
file_eggs.lock().unwrap().push(egg);
|
file_eggs.lock().unwrap().push(egg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -34,15 +34,9 @@ impl<'a, 'dir> FileName<'a, 'dir> {
|
|||||||
/// Create a new `FileName` that prints the given file’s name, painting it
|
/// Create a new `FileName` that prints the given file’s name, painting it
|
||||||
/// with the remaining arguments.
|
/// with the remaining arguments.
|
||||||
pub fn new(file: &'a File<'dir>, link_style: LinkStyle, classify: Classify, colours: &'a Colours) -> FileName<'a, 'dir> {
|
pub fn new(file: &'a File<'dir>, link_style: LinkStyle, classify: Classify, colours: &'a Colours) -> FileName<'a, 'dir> {
|
||||||
let target = if file.is_link() { Some(file.link_target()) }
|
let target = if file.is_link() { Some(file.link_target()) }
|
||||||
else { None };
|
else { None };
|
||||||
FileName {
|
FileName { file, colours, target, link_style, classify }
|
||||||
file: file,
|
|
||||||
colours: colours,
|
|
||||||
target: target,
|
|
||||||
link_style: link_style,
|
|
||||||
classify: classify,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user