squiggle/packages/cli
Vyacheslav Matyukhin 2d9fea4f21
Merge pull request #1244 from quantified-uncertainty/squiggle-cli-docs-2022-10-10
tweak: Add more verbose documentation to the cli README
2022-10-12 10:59:50 +03:00
..
.gitignore First attempt at new CLI 2022-06-17 21:45:58 -07:00
index.js some linty thing apparently 2022-06-20 11:51:09 -04:00
package.json more turbo; rewrite and simplify github CI 2022-10-08 17:28:43 +04:00
README.md Ran formatting 2022-10-11 18:58:35 -07:00

Squiggle CLI

This package can be used to incorporate a very simple import system into Squiggle.

To use, write special files with a .squiggleU file type. In these files, you can write lines like,

@import(models/gdp_over_time.squiggle, gdpOverTime)
gdpOverTime(2.5)

The imports will be replaced with the contents of the file in models/gdp_over_time.squiggle upon compilation. The .squiggleU file will be converted into a .squiggle file with the import statement having this replacement.

Running

npx squiggle-cli-experimental compile

Runs compilation in the current directory and all of its subdirectories.

npx squiggle-cli-experimental watch

Watches .squiggleU files in the current directory (and subdirectories) and rebuilds them when they are saved. Note that this will not rebuild files when their dependencies are changed, just when they are changed directly.

Further instructions

The above requires having node, npm and npx. To install the first two, see here, to install npx, run:

npm install -g npx

Alternatively, you can run the following without the need for npx:

npm install squiggle-cli-experimental
node node_modules/squiggle-cli-experimental/index.js compile

or you can add a script to your package.json, like:

 ...
 scripts: {
  "compile": "squiggle-cli-experimental compile"
 }
 ...

This can be run with npm run compile. npm knows how to reach into the node_modules directly, so it's not necessary to specify that.