From d608ffeeda1a479c9dc0e5f6ad269ba07a510d7f Mon Sep 17 00:00:00 2001 From: Andrew Guschin Date: Fri, 30 Oct 2026 03:10:41 +0400 Subject: Implement Linux proxy controller, subscription state, and CLI/TUI --- src/editor.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/editor.rs (limited to 'src/editor.rs') diff --git a/src/editor.rs b/src/editor.rs new file mode 100644 index 0000000..3207fb9 --- /dev/null +++ b/src/editor.rs @@ -0,0 +1,26 @@ +use anyhow::{Context, Result, ensure}; +use std::{io::Write, process::Command}; + +pub fn open(lines: &[String]) -> Result<()> { + let editor = std::env::var("EDITOR").unwrap_or_else(|_| "vi".into()); + let args = shell_words::split(&editor).context("Invalid quoting in EDITOR")?; + ensure!( + !args.is_empty(), + "EDITOR is empty; configure an editor command" + ); + let mut snapshot = tempfile::Builder::new() + .prefix("roentgen-logs-") + .suffix(".txt") + .tempfile()?; + for line in lines { + writeln!(snapshot, "{}", crate::model::display_text(line))?; + } + snapshot.flush()?; + let status = Command::new(&args[0]) + .args(&args[1..]) + .arg(snapshot.path()) + .status() + .context("Could not launch EDITOR")?; + ensure!(status.success(), "Editor exited unsuccessfully"); + Ok(()) +} -- cgit v1.2.3