feat: new fmt command and pretty printing works
This commit is contained in:
@@ -31,6 +31,9 @@ pub enum UplcCommand {
|
||||
#[clap(short, long)]
|
||||
out: Option<String>,
|
||||
},
|
||||
Fmt {
|
||||
input: PathBuf,
|
||||
},
|
||||
}
|
||||
|
||||
impl Default for Args {
|
||||
|
||||
@@ -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)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user