use std::path::PathBuf;
use anyhow::{Context, Result};
pub(crate) fn run_show(explicit: Option<PathBuf>) -> Result<String> {
let cfg = super::load(explicit)?;
Ok(render(&cfg))
}
pub(crate) fn run_set_device(address: &str) -> Result<String> {
::config::set_device(address).context("writing device address to user config")?;
Ok(format!("device.address = {address}"))
}
fn render(cfg: &::config::Config) -> String {
format!(
"device.address = {}\n\
device.map_channel = {}\n\
device.pbap_channel = {}\n\
hub.node_key = {}",
cfg.device.address(),
cfg.device.map_channel,
cfg.device.pbap_channel,
cfg.hub.node_key.as_deref().unwrap_or("<not set>"),
)
}