Обновление README.md, исходников, пакетки
This commit is contained in:
@ -8,12 +8,12 @@ use std::path::Path;
|
||||
|
||||
|
||||
pub fn get_stage_hook(stage: &str) -> io::Result<String> {
|
||||
let cfg_path = &crate::commands::get_etc_path().join("aeropkg.md");
|
||||
let cfg_path = &crate::commands::get_aeropkg_etc().join("aeropkg.md");
|
||||
extract_block(cfg_path, &format!("``` sh *** hook {} ***", &stage), "```")
|
||||
}
|
||||
|
||||
pub fn get_repo_and_stage_hook(repo: &str, stage: &str) -> io::Result<String> {
|
||||
let cfg_path = &crate::commands::get_etc_path().join("aeropkg.md");
|
||||
let cfg_path = &crate::commands::get_aeropkg_etc().join("aeropkg.md");
|
||||
extract_block(cfg_path, &format!("``` sh *** hook {} {} ***", &repo, &stage), "```")
|
||||
}
|
||||
|
||||
@ -23,29 +23,19 @@ pub fn get_build_deps(file_path: &Path) -> io::Result<String> { extract_block(fi
|
||||
pub fn get_run_deps(file_path: &Path) -> io::Result<String> { extract_block(file_path, "``` cfg *** run deps ***", "```") }
|
||||
pub fn get_build_script(file_path: &Path) -> io::Result<String> { extract_block(file_path, "``` sh *** build ***", "```") }
|
||||
pub fn get_config_script(file_path: &Path) -> io::Result<String> { extract_block(file_path, "``` sh *** config ***", "```") }
|
||||
pub fn get_patch_script(file_path: &Path) -> io::Result<String> { extract_block(file_path, "``` sh *** config ***", "```") }
|
||||
pub fn get_patch_script(file_path: &Path) -> io::Result<String> { extract_block(file_path, "``` sh *** patch ***", "```") }
|
||||
pub fn get_custom_script(file_path: &Path, scriptname: &String) -> String { extract_block(file_path, &format!("``` sh *** {} ***", scriptname), "```").expect(&format!("Can't get custom script: {}", &scriptname)) }
|
||||
|
||||
fn extract_block(
|
||||
file_path: &Path,
|
||||
start_marker: &str,
|
||||
end_marker: &str,
|
||||
) -> io::Result<String> {
|
||||
fn extract_block(file_path: &Path, start_marker: &str, end_marker: &str) -> io::Result<String> {
|
||||
let lines = read_lines(file_path)?;
|
||||
let mut block_started = false;
|
||||
let mut result = Vec::new();
|
||||
|
||||
for line in lines {
|
||||
if line.trim() == start_marker {
|
||||
block_started = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if line.trim() == start_marker { block_started = true; continue }
|
||||
if block_started {
|
||||
if line.trim() == end_marker {
|
||||
break;
|
||||
}
|
||||
result.push(line.trim().to_string());
|
||||
if line.trim() == end_marker { break }
|
||||
result.push(line.trim().to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user