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

19 lines
441 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 16:13:54 +00:00
const project = SqProject.create();
const src = process.argv[2];
if (!src) {
throw new Error("Expected src");
}
console.log(`Running ${src}`);
2022-09-18 16:13:54 +00:00
project.setSource("a", src);
project.run("a");
2022-09-18 16:13:54 +00:00
const result = project.getResult("a");
console.log(result.tag, result.value.toString());
2022-09-18 16:13:54 +00:00
const bindings = project.getBindings("a");
console.log(bindings.asValue().toString());