use newt_core::agentic::print_newt;
use crate::{render_help, VERSION};
pub(crate) fn dispatch(
cmd: &str,
arg1: &str,
workspace: &str,
color: bool,
verbose: bool,
) -> anyhow::Result<bool> {
match cmd {
"exit" | "quit" => return Ok(false),
"help" => print!("{}", render_help(None, color, verbose)),
"version" => print_newt(&format!("v{VERSION}"), color, verbose),
"workspace" => print_newt(workspace, color, verbose),
"config" => match arg1 {
"show" => match newt_core::Config::resolve() {
Ok(cfg) => match cfg.to_redacted_toml() {
Ok(toml_str) => {
print_newt("Resolved config (secrets redacted):", color, verbose);
println!("{toml_str}");
}
Err(e) => {
print_newt(&format!("error serializing config: {e}"), color, verbose);
}
},
Err(e) => print_newt(&format!("error resolving config: {e}"), color, verbose),
},
_ => print_newt(
"settings interface not implemented yet — try `/config show` to dump the resolved config",
color,
verbose,
),
},
other => unreachable!("commands::meta::dispatch routed a non-meta command: {other:?}"),
}
Ok(true)
}