squiggle/packages/squiggle-lang/scripts/run-project.mjs
2022-09-28 14:14:35 +10:00

29 lines
624 B
JavaScript
Executable File

#!/usr/bin/env node
import fs from "fs";
import { Command } from "commander";
import { SqProject } from "@quri/squiggle-lang";
import { runProject } from "./lib.mjs";
const program = new Command();
program.option("-o, --output");
program.arguments("<string>");
const options = program.parse(process.argv);
const sampleCount = process.env.SAMPLE_COUNT ?? 10000;
console.log(sampleCount);
const src = fs.readFileSync(program.args[0], "utf-8");
if (!src) {
throw new Error("Expected src");
}
const projectJson = JSON.parse(src);
const project = SqProject.fromJson(projectJson);
runProject(project, options.output);