mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-26 13:56:27 +00:00
Merge branch 'fix-warnings-and-rust-2018' of https://github.com/ariasuni/exa into ariasuni-fix-warnings-and-rust-2018
# Conflicts: # src/fs/dir.rs
This commit is contained in:
commit
081bce0479
@ -11,7 +11,7 @@ fn main() {
|
|||||||
configure_logger();
|
configure_logger();
|
||||||
|
|
||||||
let args: Vec<OsString> = args_os().skip(1).collect();
|
let args: Vec<OsString> = args_os().skip(1).collect();
|
||||||
match Exa::new(args.iter(), &mut stdout()) {
|
match Exa::from_args(args.iter(), &mut stdout()) {
|
||||||
Ok(mut exa) => {
|
Ok(mut exa) => {
|
||||||
match exa.run() {
|
match exa.run() {
|
||||||
Ok(exit_status) => exit(exit_status),
|
Ok(exit_status) => exit(exit_status),
|
||||||
|
@ -100,7 +100,7 @@ fn ignore_cache(options: &Options) -> Option<IgnoreCache> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'args, 'w, W: Write + 'w> Exa<'args, 'w, W> {
|
impl<'args, 'w, W: Write + 'w> Exa<'args, 'w, W> {
|
||||||
pub fn new<I>(args: I, writer: &'w mut W) -> Result<Exa<'args, 'w, W>, Misfire>
|
pub fn from_args<I>(args: I, writer: &'w mut W) -> Result<Exa<'args, 'w, W>, Misfire>
|
||||||
where I: Iterator<Item=&'args OsString> {
|
where I: Iterator<Item=&'args OsString> {
|
||||||
Options::parse(args, &LiveVars).map(move |(options, mut args)| {
|
Options::parse(args, &LiveVars).map(move |(options, mut args)| {
|
||||||
debug!("Dir action from arguments: {:#?}", options.dir_action);
|
debug!("Dir action from arguments: {:#?}", options.dir_action);
|
||||||
@ -125,7 +125,7 @@ impl<'args, 'w, W: Write + 'w> Exa<'args, 'w, W> {
|
|||||||
let mut exit_status = 0;
|
let mut exit_status = 0;
|
||||||
|
|
||||||
for file_path in &self.args {
|
for file_path in &self.args {
|
||||||
match File::new(PathBuf::from(file_path), None, None) {
|
match File::from_args(PathBuf::from(file_path), None, None) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
exit_status = 2;
|
exit_status = 2;
|
||||||
writeln!(stderr(), "{:?}: {}", file_path, e)?;
|
writeln!(stderr(), "{:?}: {}", file_path, e)?;
|
||||||
|
@ -82,7 +82,7 @@ pub struct Files<'dir, 'ig> {
|
|||||||
|
|
||||||
/// Whether the `.` or `..` directories should be produced first, before
|
/// Whether the `.` or `..` directories should be produced first, before
|
||||||
/// any files have been listed.
|
/// any files have been listed.
|
||||||
dots: Dots,
|
dots: DotsNext,
|
||||||
|
|
||||||
ignore: Option<&'ig IgnoreCache>,
|
ignore: Option<&'ig IgnoreCache>,
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ impl<'dir, 'ig> Files<'dir, 'ig> {
|
|||||||
if i.is_ignored(path) { continue }
|
if i.is_ignored(path) { continue }
|
||||||
}
|
}
|
||||||
|
|
||||||
return Some(File::new(path.clone(), self.dir, filename)
|
return Some(File::from_args(path.clone(), self.dir, filename)
|
||||||
.map_err(|e| (path.clone(), e)))
|
.map_err(|e| (path.clone(), e)))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -121,16 +121,16 @@ impl<'dir, 'ig> Files<'dir, 'ig> {
|
|||||||
|
|
||||||
/// The dot directories that need to be listed before actual files, if any.
|
/// The dot directories that need to be listed before actual files, if any.
|
||||||
/// If these aren’t being printed, then `FilesNext` is used to skip them.
|
/// If these aren’t being printed, then `FilesNext` is used to skip them.
|
||||||
enum Dots {
|
enum DotsNext {
|
||||||
|
|
||||||
/// List the `.` directory next.
|
/// List the `.` directory next.
|
||||||
DotNext,
|
Dot,
|
||||||
|
|
||||||
/// List the `..` directory next.
|
/// List the `..` directory next.
|
||||||
DotDotNext,
|
DotDot,
|
||||||
|
|
||||||
/// Forget about the dot directories and just list files.
|
/// Forget about the dot directories and just list files.
|
||||||
FilesNext,
|
Files,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -138,18 +138,20 @@ impl<'dir, 'ig> Iterator for Files<'dir, 'ig> {
|
|||||||
type Item = Result<File<'dir>, (PathBuf, io::Error)>;
|
type Item = Result<File<'dir>, (PathBuf, io::Error)>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if let Dots::DotNext = self.dots {
|
match self.dots {
|
||||||
self.dots = Dots::DotDotNext;
|
DotsNext::Dot => {
|
||||||
|
self.dots = DotsNext::DotDot;
|
||||||
Some(File::new_aa_current(self.dir)
|
Some(File::new_aa_current(self.dir)
|
||||||
.map_err(|e| (Path::new(".").to_path_buf(), e)))
|
.map_err(|e| (Path::new(".").to_path_buf(), e)))
|
||||||
}
|
},
|
||||||
else if let Dots::DotDotNext = self.dots {
|
DotsNext::DotDot => {
|
||||||
self.dots = Dots::FilesNext;
|
self.dots = DotsNext::Files;
|
||||||
Some(File::new_aa_parent(self.parent(), self.dir)
|
Some(File::new_aa_parent(self.parent(), self.dir)
|
||||||
.map_err(|e| (self.parent(), e)))
|
.map_err(|e| (self.parent(), e)))
|
||||||
}
|
},
|
||||||
else {
|
DotsNext::Files => {
|
||||||
self.next_visible_file()
|
self.next_visible_file()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,11 +191,11 @@ impl DotFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Whether this filter should add dot directories to a listing.
|
/// Whether this filter should add dot directories to a listing.
|
||||||
fn dots(self) -> Dots {
|
fn dots(self) -> DotsNext {
|
||||||
match self {
|
match self {
|
||||||
DotFilter::JustFiles => Dots::FilesNext,
|
DotFilter::JustFiles => DotsNext::Files,
|
||||||
DotFilter::Dotfiles => Dots::FilesNext,
|
DotFilter::Dotfiles => DotsNext::Files,
|
||||||
DotFilter::DotfilesAndDots => Dots::DotNext,
|
DotFilter::DotfilesAndDots => DotsNext::Dot,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ pub struct File<'dir> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'dir> File<'dir> {
|
impl<'dir> File<'dir> {
|
||||||
pub fn new<PD, FN>(path: PathBuf, parent_dir: PD, filename: FN) -> IOResult<File<'dir>>
|
pub fn from_args<PD, FN>(path: PathBuf, parent_dir: PD, filename: FN) -> IOResult<File<'dir>>
|
||||||
where PD: Into<Option<&'dir Dir>>,
|
where PD: Into<Option<&'dir Dir>>,
|
||||||
FN: Into<Option<String>>
|
FN: Into<Option<String>>
|
||||||
{
|
{
|
||||||
@ -149,7 +149,7 @@ impl<'dir> File<'dir> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If this file is a directory on the filesystem, then clone its
|
/// If this file is a directory on the filesystem, then clone its
|
||||||
|
@ -29,6 +29,7 @@ pub struct View {
|
|||||||
|
|
||||||
/// The **mode** is the “type” of output.
|
/// The **mode** is the “type” of output.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum Mode {
|
pub enum Mode {
|
||||||
Grid(grid::Options),
|
Grid(grid::Options),
|
||||||
Details(details::Options),
|
Details(details::Options),
|
||||||
|
@ -323,6 +323,7 @@ impl render::FiletypeColours for Colours {
|
|||||||
|
|
||||||
impl render::GitColours for Colours {
|
impl render::GitColours for Colours {
|
||||||
fn not_modified(&self) -> Style { self.punctuation }
|
fn not_modified(&self) -> Style { self.punctuation }
|
||||||
|
#[allow(clippy::new_ret_no_self)]
|
||||||
fn new(&self) -> Style { self.git.new }
|
fn new(&self) -> Style { self.git.new }
|
||||||
fn modified(&self) -> Style { self.git.modified }
|
fn modified(&self) -> Style { self.git.modified }
|
||||||
fn deleted(&self) -> Style { self.git.deleted }
|
fn deleted(&self) -> Style { self.git.deleted }
|
||||||
|
Loading…
Reference in New Issue
Block a user