use anyhow::{Context, Result};
use crate::config::{self, Config};
pub fn run(arg: Option<String>) -> Result<()> {
match arg {
None => {
let cfg = Config::load();
match cfg.editor.as_deref() {
Some(e) => println!("{e}"),
None => println!("(unset) — try `bosun editor zed` or `bosun editor code`"),
}
Ok(())
}
Some(cmd) => {
let trimmed = cmd.trim();
if trimmed.is_empty() {
config::write_editor(None).context("write config.toml")?;
println!("editor cleared");
} else {
config::write_editor(Some(trimmed)).context("write config.toml")?;
println!("editor set to: {trimmed}");
println!("(restart bosun for the TUI to pick up the change)");
}
Ok(())
}
}
}