Обновление README.md, исходников, пакетки
This commit is contained in:
@ -32,14 +32,16 @@ pub fn get_custom_env(repo: &String, pkgname: &String, pkg_md_path: &Path) -> Ha
|
||||
|
||||
pub fn get_global_env() -> HashMap<String, String> {
|
||||
let mut full_env = HashMap::new();
|
||||
full_env.insert("repo".to_string(), repo.clone());
|
||||
full_env.insert("pkgname".to_string(), pkgname.clone());
|
||||
full_env.insert("aeropkg_home".to_string(), crate::commands::get_aeropkg_home().to_string_lossy().into_owned().clone());
|
||||
full_env.insert("aeropkg_base".to_string(), crate::commands::get_aeropkg_base().to_string_lossy().into_owned().clone());
|
||||
full_env.insert("aeropkg_etc".to_string(), crate::commands::get_aeropkg_etc().to_string_lossy().into_owned().clone());
|
||||
full_env.insert("aeropkg_var".to_string(), crate::commands::get_aeropkg_var().to_string_lossy().into_owned().clone());
|
||||
if let Some(global_env) = get_global_env_string().ok() { full_env.extend(global_env) }
|
||||
return full_env
|
||||
}
|
||||
|
||||
fn get_global_env_string() -> io::Result<HashMap<String, String>> {
|
||||
let cfg_path = crate::commands::get_etc_path().join("aeropkg.md");
|
||||
let cfg_path = crate::commands::get_aeropkg_etc().join("aeropkg.md");
|
||||
let content = extract_block(&cfg_path, &format!("``` env *** env ***"), "```")?;
|
||||
Ok(parse_env_vars(&content))
|
||||
}
|
||||
@ -49,13 +51,9 @@ fn parse_env_vars(content: &str) -> HashMap<String, String> {
|
||||
.lines()
|
||||
.filter_map(|line| {
|
||||
let line = line.trim();
|
||||
if line.is_empty() || line.starts_with('#') {
|
||||
return None;
|
||||
}
|
||||
if line.is_empty() || line.starts_with('#') { return None }
|
||||
let parts: Vec<&str> = line.splitn(2, '=').collect();
|
||||
if parts.len() != 2 {
|
||||
return None;
|
||||
}
|
||||
if parts.len() != 2 { return None }
|
||||
Some((parts[0].to_string(), parts[1].to_string()))
|
||||
})
|
||||
.collect()
|
||||
@ -68,19 +66,19 @@ pub fn get_pkg_env(file_path: &Path) -> io::Result<HashMap<String, String>> {
|
||||
|
||||
|
||||
pub fn get_repo_env(repo: &str) -> io::Result<HashMap<String, String>> {
|
||||
let cfg_path = crate::commands::get_etc_path().join("aeropkg.md");
|
||||
let cfg_path = crate::commands::get_aeropkg_etc().join("aeropkg.md");
|
||||
let content = extract_block(&cfg_path, &format!("``` env *** env {} ***", repo), "```")?;
|
||||
Ok(parse_env_vars(&content))
|
||||
}
|
||||
|
||||
pub fn get_stage_env(stage: &str) -> io::Result<HashMap<String, String>> {
|
||||
let cfg_path = crate::commands::get_etc_path().join("aeropkg.md");
|
||||
let cfg_path = crate::commands::get_aeropkg_etc().join("aeropkg.md");
|
||||
let content = extract_block(&cfg_path, &format!("``` env *** env {} ***", stage), "```")?;
|
||||
Ok(parse_env_vars(&content))
|
||||
}
|
||||
|
||||
pub fn get_repo_and_stage_env(repo: &str, stage: &str) -> io::Result<HashMap<String, String>> {
|
||||
let cfg_path = crate::commands::get_etc_path().join("aeropkg.md");
|
||||
let cfg_path = crate::commands::get_aeropkg_etc().join("aeropkg.md");
|
||||
let content = extract_block(&cfg_path, &format!("``` env *** env {} {} ***", repo, stage), "```")?;
|
||||
Ok(parse_env_vars(&content))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user