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 mirror;
14pub mod pkgsrc;
15
16#[derive(Clone, Debug, Display, EnumIter, PartialEq, ValueEnum)]
18pub enum PackageRepositories {
19 #[strum(to_string = "core")]
23 Core,
24
25 #[strum(to_string = "extra")]
29 Extra,
30
31 #[strum(to_string = "multilib")]
35 Multilib,
36}
37
38pub fn filenames_in_dir(path: &Path) -> Result<HashSet<String>> {
40 let entries = read_dir(path)?;
41 let entries: Vec<DirEntry> = entries.collect::<Result<Vec<DirEntry>, std::io::Error>>()?;
42 let files: HashSet<String> = entries
43 .iter()
44 .map(|entry| entry.file_name().to_string_lossy().to_string())
45 .collect();
46
47 Ok(files)
48}