1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
pub mod contract;
pub mod error;
pub mod field;
pub mod transition;
pub mod r#type;

pub use contract::*;
pub use error::Error;
pub use field::*;
pub use r#type::*;
pub use transition::*;

use std::{path::Path, process::Command};

/// Run the scilla-fmt command using docker to generate a s-expression out of a given scilla contract.
pub fn run_scilla_fmt(path: &Path) -> Result<String, Error> {
    //docker run --rm -v contract.scilla:/tmp/input.scilla  -i zilliqa/scilla:v0.13.3 /scilla/0/bin/scilla-fmt --sexp --human-readable -d /tmp/input.scilla
    let volume = &format!(
        "{}:/tmp/input.scilla",
        path.canonicalize().unwrap().display()
    );

    let output = Command::new("docker")
        .args([
            "run",
            "--rm",
            "-v",
            volume,
            "-i",
            "zilliqa/scilla:v0.13.3",
            "/scilla/0/bin/scilla-fmt",
            "--sexp",
            "--human-readable",
            "-d",
            "/tmp/input.scilla",
        ])
        .output()?;

    Ok(String::from_utf8(output.stdout)?)
}