1use std::{
4 collections::HashSet,
5 fs::{DirEntry, read_dir},
6 path::Path,
7};
8
9use anyhow::Result;
10use clap::ValueEnum;
11use strum::{Display, EnumIter};
12
13pub mod aur;
14pub mod mirror;
15pub mod pkgsrc;
16
17#[derive(Clone, Debug, Display, EnumIter, PartialEq, ValueEnum)]
19pub enum PackageRepositories {
20 #[strum(to_string = "core")]
24 Core,
25
26 #[strum(to_string = "extra")]
30 Extra,
31
32 #[strum(to_string = "multilib")]
36 Multilib,
37}
38
39pub fn filenames_in_dir(path: &Path) -> Result<HashSet<String>> {
41 let entries = read_dir(path)?;
42 let entries: Vec<DirEntry> = entries.collect::<Result<Vec<DirEntry>, std::io::Error>>()?;
43 let files: HashSet<String> = entries
44 .iter()
45 .map(|entry| entry.file_name().to_string_lossy().to_string())
46 .collect();
47
48 Ok(files)
49}