feat: basic autofmt

This commit is contained in:
Jonathan Kelley committed 2022-04-24 03:24:41 -04:00
1 parent 3269b2b5aa
commit 84f0245f6c
9 files changed
+127 -38

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
use super::*;
/// Build the Rust WASM app and all of its assets.
#[derive(Clone, Debug, Parser)]
pub struct Autoformat {
/// Input file
#[clap(short, long)]
pub raw: Option<String>,
}
impl Autoformat {
pub fn autoformat(self) -> Result<()> {
if let Some(raw) = self.raw {
if let Some(inner) = dioxus_autofmt::fmt_block(&raw) {
println!("{}", inner);
} else {
// exit process with error
eprintln!("error formatting codeblock");
exit(1);
}
}
Ok(())
}
}