List files and folders in current dir with special handling for tty
OsStr conversion

According to the path source, s.as_os_str().to_str() is the same as s.to_str():

pub fn as_os_str(&amp;self) -&gt; &amp;OsStr {
    &amp;self.inner
}

pub fn to_str(&amp;self) -&gt; Option&lt;&amp;str&gt; {
    self.inner.to_str()
}


Moreover, using unwrap() here is not safe at all as invalid Unicode is pretty common (e.g. when mounting file system with alien character encoding). There is Path::to_string_lossy that converts path to a printable string.



Using crossterm

crossterm provides helper macros to output strings. It is more idiomatic to use them instead of println!("{}{}", ...): execute and queue.

Using queue may be beneficial in case of outputting to the pipe instead of stdout.



Reporting errors

It is common practice to report errors to stderr. It also may be more helpful to show error reason when fs::read_dir() fails. You can also use crossterm to make it more colorful:

match fs::read_dir(dir) {
    Err(err) =&gt;
        execute!(
            stdout(),
            Colored::Fg(Color::Red),
            Output(format!("Failed to list {}: {}", dir.to_string_lossy(), err)),
            Reset),
    Ok(entries) =&gt; ..
}




Callbacks

Using callbacks to print colorful vs. normal is a nice idea, but is not future-proof. It will be hard to add other output options like short/long view, hidden files, etc.