* add docsmg tool * moved to the correct scripts directory * removed test files * added install script and readme draft to docsmg * fix install script * fixed issues * Revert "fixed issues" This reverts commita51192025f. * Revert "Revert "fixed issues"" This reverts commitab68918fea. * added dotenv and updated readme * fixed install script
36 lines
1.0 KiB
Rust
36 lines
1.0 KiB
Rust
use std::{fs::read_to_string, path::PathBuf};
|
|
|
|
pub fn read_migrate_file(file: PathBuf) -> anyhow::Result<Vec<(PathBuf, PathBuf)>> {
|
|
let contents = read_to_string(file)?;
|
|
let lines: Vec<String> = contents
|
|
.split('\n')
|
|
.map(|x| x.to_owned())
|
|
.filter(|x| x != "")
|
|
.collect();
|
|
let migrations = lines
|
|
.iter()
|
|
.filter_map(|x| x.split_once(" -> "))
|
|
.map(|x| {
|
|
(
|
|
x.0.parse().expect("a valid path"),
|
|
x.1.parse().expect("a valid path"),
|
|
)
|
|
})
|
|
.collect::<Vec<_>>();
|
|
Ok(migrations)
|
|
}
|
|
|
|
pub fn read_migrate_file_left_side(file: PathBuf) -> anyhow::Result<Vec<PathBuf>> {
|
|
let contents = read_to_string(file)?;
|
|
let lines: Vec<String> = contents
|
|
.split('\n')
|
|
.map(|x| x.to_owned())
|
|
.filter(|x| x != "")
|
|
.collect();
|
|
let migrations = lines
|
|
.iter()
|
|
.map(|x| x.split(" -> ").collect::<Vec<&str>>()[0].into())
|
|
.collect::<Vec<_>>();
|
|
Ok(migrations)
|
|
}
|