independant_editor/
independant_editor.rs1use std::{fs, path::PathBuf, str::FromStr, thread::sleep, time::Duration};
2
3use open_editor::EditorCallBuilder;
4
5fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let filename = PathBuf::from_str("./test")?;
9
10 EditorCallBuilder::new()
12 .wait_for_editor(false)
13 .open_file(&filename)?;
14
15 println!("Editor launched. Press Ctrl+C to stop.\n");
16
17 loop {
18 let contents = fs::read_to_string(&filename).unwrap_or_default();
19
20 println!("--- Content of {} ---\n{}\n", filename.display(), contents);
21
22 sleep(Duration::from_secs(1));
23 }
24}