use std::{fs::read_to_string, path::PathBuf};
use typstyle_core::{Config, Typstyle};
#[derive(Debug, Clone, Default)]
pub struct FormatParams {
pub input: PathBuf,
pub column: usize,
pub tab_spaces: usize,
}
pub fn format(params: &FormatParams) -> Result<String, Box<dyn std::error::Error>> {
let config = Config::new()
.with_width(params.column)
.with_tab_spaces(params.tab_spaces);
let result = Typstyle::new(config)
.format_text(&read_to_string(¶ms.input)?)
.render()
.map_err(|why| why.to_string())?;
Ok(result)
}