vim
parent
bef9ef1a2a
commit
65bc42c246
|
|
@ -581,6 +581,17 @@ mod tests {
|
||||||
pub fn file_content(p: &String) -> String {
|
pub fn file_content(p: &String) -> String {
|
||||||
std::fs::read_to_string(p).unwrap()
|
std::fs::read_to_string(p).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn list_dir(d: &tempdir::TempDir) -> Vec<String> {
|
||||||
|
std::fs::read_dir(d)
|
||||||
|
.unwrap()
|
||||||
|
.filter(|x| x.is_ok())
|
||||||
|
.map(|x| x.unwrap())
|
||||||
|
.filter(|x| x.metadata().unwrap().is_file())
|
||||||
|
.map(|x| x.path().display().to_string())
|
||||||
|
.filter(|x| !x.contains("/."))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod edit {
|
mod edit {
|
||||||
|
|
@ -603,7 +614,19 @@ mod edit {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn edit_dir(d: &tempdir::TempDir) -> Result<(), String> {
|
fn edit_dir(d: &tempdir::TempDir) -> Result<(), String> {
|
||||||
panic!("not impl");
|
let mut cmd = std::process::Command::new("vim");
|
||||||
|
cmd.stdout(std::process::Stdio::inherit());
|
||||||
|
cmd.stdin(std::process::Stdio::inherit());
|
||||||
|
cmd.stderr(std::process::Stdio::inherit());
|
||||||
|
cmd.arg("-p");
|
||||||
|
for f in tests::list_dir(&d).iter() {
|
||||||
|
cmd.arg(Events::basename(f));
|
||||||
|
}
|
||||||
|
cmd.current_dir(d.path().display().to_string());
|
||||||
|
match cmd.output() {
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(msg) => Err(format!("failed to vim: {}", msg)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn persist_edits(d: &tempdir::TempDir, files: &Files) -> Result<(), String> {
|
fn persist_edits(d: &tempdir::TempDir, files: &Files) -> Result<(), String> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue