before index-conflict changes
This commit is contained in:
38
src/utils/parser/repoinfo.rs
Normal file
38
src/utils/parser/repoinfo.rs
Normal file
@ -0,0 +1,38 @@
|
||||
use super::*;
|
||||
|
||||
pub fn get_repo_addr(repo: &str) -> String {
|
||||
let file_path = &crate::commands::get_etc_path().join("aeropkg.md");
|
||||
|
||||
let block = extract_block(file_path, "``` cfg *** Repository list and priority ***", "```").expect("Can't parse repo list block");
|
||||
|
||||
for line in block.lines() {
|
||||
let trimmed_line = line.trim();
|
||||
if !trimmed_line.is_empty() {
|
||||
let parts: Vec<&str> = trimmed_line.split_whitespace().collect();
|
||||
if parts.len() >= 2 && parts[0] == repo {
|
||||
return parts[1].to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
panic!("Repository '{}' not found in the repository list", repo);
|
||||
}
|
||||
|
||||
pub fn get_repo_list() -> Vec<String> {
|
||||
let file_path = &crate::commands::get_etc_path().join("aeropkg.md");
|
||||
|
||||
let block = extract_block(file_path, "``` cfg *** Repository list and priority ***", "```").expect("Can't parse repo list block");
|
||||
|
||||
let mut repo_list = Vec::new();
|
||||
for line in block.lines() {
|
||||
let trimmed_line = line.trim();
|
||||
if !trimmed_line.is_empty() {
|
||||
let parts: Vec<&str> = trimmed_line.split_whitespace().collect();
|
||||
if let Some(repo) = parts.first() {
|
||||
repo_list.push(repo.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repo_list
|
||||
}
|
||||
Reference in New Issue
Block a user