use markdown_formatter::args::Args;
use markdown_formatter::format;
use std::env;
use std::fs;
use std::path::PathBuf;
#[cfg(feature = "formatter")]
fn main() {
let args = Args::parse(env::args().collect()).unwrap();
if args.print_config {
args.print_config();
}
let mut input_file = PathBuf::from(args.input.clone());
if !input_file.exists() {
panic!("`{}` 不是合法的文件路径", input_file.to_str().unwrap());
}
let mut content = fs::read_to_string(input_file.clone()).unwrap();
content = format(&args, content);
input_file.set_extension(format!(
"output.{}",
input_file.clone().extension().unwrap().to_str().unwrap()
));
fs::write(input_file, content).unwrap();
}
#[cfg(all(feature = "debug", feature = "formatter"))]
compile_error!("Cannot enable debug when formatter enabled");