feat: bring over the formatter from gleam

This commit is contained in:
rvcas
2022-11-01 19:53:19 -04:00
parent 91a131d520
commit cba7a6f46e
32 changed files with 2270 additions and 480 deletions

31
crates/cli/src/cmd/fmt.rs Normal file
View File

@@ -0,0 +1,31 @@
#[derive(clap::Args)]
/// Create a new Aiken project
pub struct Args {
/// Files to format
#[clap(default_value = ".")]
files: Vec<String>,
/// Read source from STDIN
#[clap(long)]
stdin: bool,
/// Check if inputs are formatted without changing them
#[clap(long)]
check: bool,
}
pub fn exec(
Args {
check,
stdin,
files,
}: Args,
) -> miette::Result<()> {
if let Err(err) = aiken_project::format::run(stdin, check, files) {
err.report();
miette::bail!("failed: {} error(s)", err.total());
};
Ok(())
}