Remove unused code and simplify main function
Some checks failed
Rust-lint / Run rust tests (push) Successful in 32s
Rust-lint / Check Rust code with rustfmt and clippy (push) Failing after 18s

This commit is contained in:
2025-02-25 23:24:57 +09:00
parent 54bbe1eef5
commit 9bdac01006
2 changed files with 1 additions and 49 deletions

0
src/lib.rs Normal file
View File

View File

@@ -1,6 +1,4 @@
use clap::{ArgAction, Parser};
use std::fs;
use std::path::{Path, PathBuf};
/// Represents the command-line arguments for the ls program
#[derive(Parser)]
@@ -267,52 +265,6 @@ struct Args {
one_per_line: bool,
}
#[derive(Debug)]
enum Error {
Io(std::io::Error),
StripPrefix(std::path::StripPrefixError),
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
}
impl From<std::path::StripPrefixError> for Error {
fn from(e: std::path::StripPrefixError) -> Self {
Error::StripPrefix(e)
}
}
fn get_list<T>(path: T) -> Result<Vec<PathBuf>, Error>
where
T: AsRef<Path> + Copy,
{
match fs::metadata(&path) {
Ok(md) => {
if md.is_dir() {
let entries = fs::read_dir(path)?;
let mut list = Vec::new();
for entry in entries {
let entry_path = entry?.path();
let relative = entry_path.strip_prefix(&path)?;
list.push(relative.to_owned());
}
Ok(list)
} else {
Ok(vec![path.as_ref().to_owned()])
}
}
Err(e) => Err(Error::Io(e)),
}
}
fn main() {
let cli = Args::parse();
// let list = get_list(&cli.input).unwrap();
// for path in list {
// println!("{}", path.display());
// }
println!("{}", cli.almost_all);
let _cli = Args::parse();
}