use serde::Serialize;
use crate::config::{config_path, CONFIG_SCHEMA_VERSION};
use crate::error::CliError;
use crate::output::{self, OutputFormat, OutputSpec};
#[derive(Debug, Serialize)]
struct ConfigPathPayload {
schema_version_config: u32,
path: String,
exists: bool,
}
pub fn run(spec: &OutputSpec, warnings: &[String]) -> Result<(), CliError> {
let path = config_path()?;
let payload = ConfigPathPayload {
schema_version_config: CONFIG_SCHEMA_VERSION,
path: path.display().to_string(),
exists: path.exists(),
};
match spec.format {
OutputFormat::Json | OutputFormat::Jsonl => {
output::emit_envelope(&payload, spec, warnings)?;
}
OutputFormat::Text => {
println!("{}", payload.path);
output::emit_text_warnings(warnings);
}
}
Ok(())
}