diff options
| author | Andrew Guschin <guschin@altlinux.org> | 2026-10-30 03:10:41 +0400 |
|---|---|---|
| committer | Andrew Guschin <guschin@altlinux.org> | 2026-10-30 03:10:41 +0400 |
| commit | d608ffeeda1a479c9dc0e5f6ad269ba07a510d7f (patch) | |
| tree | 3824ec9da5ca0adac913cc47e3e20054c3dc843a /src/editor.rs | |
| parent | 40cf3276cdc74bf6f1795990ed600891a637d1fe (diff) | |
Implement Linux proxy controller, subscription state, and CLI/TUI
Diffstat (limited to 'src/editor.rs')
| -rw-r--r-- | src/editor.rs | 26 |
1 files changed, 26 insertions, 0 deletions
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(()) +} |