1use std::{
2 collections::HashSet,
3 fs::{DirEntry, read_dir},
4 path::Path,
5};
6
7use anyhow::Result;
8use clap::ValueEnum;
9use strum::{Display, EnumIter};
10
11pub mod mirror;
14pub mod pkgsrc;
18
19#[derive(Clone, Display, Debug, EnumIter, PartialEq, ValueEnum)]
21pub enum PackageRepositories {
22 #[strum(to_string = "core")]
23 Core,
24 #[strum(to_string = "extra")]
25 Extra,
26 #[strum(to_string = "multilib")]
27 Multilib,
28}
29
30pub fn filenames_in_dir(path: &Path) -> Result<HashSet<String>> {
32 let entries = read_dir(path)?;
33 let entries: Vec<DirEntry> = entries.collect::<Result<Vec<DirEntry>, std::io::Error>>()?;
34 let files: HashSet<String> = entries
35 .iter()
36 .map(|entry| entry.file_name().to_string_lossy().to_string())
37 .collect();
38
39 Ok(files)
40}