squiggle/packages/squiggle-lang/scripts/run.mjs

19 lines
411 B
JavaScript
Raw Normal View History

#!/usr/bin/env node
2022-09-18 15:18:10 +00:00
import { SqProject } from "@quri/squiggle-lang";
2022-09-18 15:18:10 +00:00
const p = SqProject.create();
const src = process.argv[2];
if (!src) {
throw new Error("Expected src");
}
console.log(`Running ${src}`);
p.setSource("a", src);
p.run("a");
const result = p.getResult("a");
console.log(result.tag, result.value.toString());
const bindings = p.getBindings("a");
console.log(bindings.asValue().toString());