feat: new fmt command and pretty printing works

This commit is contained in:
rvcas
2022-06-18 22:53:02 -04:00
committed by Lucas
parent 6a39d4349a
commit 6aae184848
6 changed files with 45 additions and 13 deletions

View File

@@ -31,6 +31,9 @@ pub enum UplcCommand {
#[clap(short, long)]
out: Option<String>,
},
Fmt {
input: PathBuf,
},
}
impl Default for Args {

View File

@@ -47,6 +47,15 @@ fn main() -> anyhow::Result<()> {
fs::write(&out_name, &bytes)?;
}
}
UplcCommand::Fmt { input } => {
let code = std::fs::read_to_string(&input)?;
let program = parser::program(&code)?;
let pretty = program.to_pretty();
fs::write(&input, pretty)?;
}
UplcCommand::Unflat { input, print, out } => {
let bytes = std::fs::read(&input)?;