minor fix

This commit is contained in:
Guilleag01
2023-11-09 18:13:32 +01:00
parent 830dc5d9ac
commit 8a690d0082
1856 changed files with 4052 additions and 0 deletions

42
src/main.rs Normal file
View File

@@ -0,0 +1,42 @@
use clap::Parser;
use lsplus::{
element::Element,
out::{default::default, list::list},
};
use std::fs;
// Needs to be defined in main
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
/// Show hidden files
#[arg(short, long, default_value_t = false)]
all: bool,
/// Print as a list
#[arg(short, long, default_value_t = false)]
list: bool,
/// Path of the directory to list
#[arg(default_value_t = String::from("."))]
path: String,
}
fn main() {
let args = Args::parse();
let paths = fs::read_dir(args.path).unwrap();
let _max_width = 50;
let elements: Vec<Element> = paths
.map(|e| Element::new(e.unwrap().path().to_str().unwrap()))
.filter(|element| args.all || !element.get_name().starts_with('.'))
.collect();
if args.list {
list(elements);
} else {
default(elements);
}
}