Rust implementation of the POSIX ls
command.
This example will print a string with all non-hidden file and directory names, sorted by creation time.
use anyhow::Result;
use lst::filters::DotFilesFilter;
use lst::formatters::NameOnlyFormatter;
use lst::readers::FileSystemReader;
use lst::sorters::TimeSorter;
use lst::validators::FileSystemValidator;
use lst::{Location, Lst};
fn main() -> Result<()> {
let mut lst = Lst::new(Location::new("./"));
lst.validator(FileSystemValidator::new())
.reader(FileSystemReader::new())
.filter(Box::new(DotFilesFilter::new()))
.sorter(Box::new(TimeSorter::new()))
.formatter(NameOnlyFormatter::new());
println!("{}", lst.generate()?);
Ok(())
}
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.